4 ms·
Clever tricks are all well and good until they bite you on the ass. Using the || to provide default parameters is great until you want to use booleans. Take the
by Digit-Al 11y ago
Clever tricks are all well and good until they bite you on the ass. Using the || to provide default parameters is great until you want to use booleans. Take the following code:
function f(x) { x = x || true; ...}
Guess what x will be if you call x(false). Guess which muggins made this mistake without thinking about it (ahem) :-)
The moral of the story - don't get too complacent with clever tricks.