Re:Default Parameters in JavaScript
by STRML on Tuesday March 19, 2013 @11:39AM
(#5401511)
You are correct, except this will not work in the significant case where any falsy value is passed ("", 0, null, NaN... I exclude undefined because that is the intended behavior) or with booleans.
A slightly more verbose, yet hardy syntax would go like this:
A slightly more verbose, yet hardy syntax would go like this:
This would catch the intended behavior, which is to fill a parameter when it is not supplied at all.