I don't think it's good to recommend using || for setting default value to variables. It's nice shortcut but it can cause trouble when valid input (0, false, '') is converted to default value. I would recommend mentioning explicitly these dangers in that chapter or add chapter about more safe default value assigning
function example(value) {
if (typeof value === 'undefined') {
value = 'defaultValue';
}
}
I don't think it's good to recommend using
||
for setting default value to variables. It's nice shortcut but it can cause trouble when valid input (0, false, '') is converted to default value. I would recommend mentioning explicitly these dangers in that chapter or add chapter about more safe default value assigning