Open mdv27 opened 7 years ago
I think that's the point. Consider this example:
function setEnable(enable) {
enable = enable || true
console.log(enable);
}
setEnable(); // true
setEnable(true); // true
setEnable(false); // true
Setting the param as false is not the same as leaving it undefined
It's mentioned that Other "falsy" values than undefined such as '', "", false, null, 0, and NaN, will not be replaced by a default value. I am doubtful as below line of code works with default value; let a = ""; let b = a || "my default value"; console.log(b) // prints my default value This even works for other falsy values.