undefined being treated as a missing optional argument

David Herman dherman at mozilla.com
Fri Apr 13 11:26:43 PDT 2012

On Apr 13, 2012, at 9:38 AM, Russell Leggett wrote:

> Yes, but as I said, and Erik pointed out is in the wiki, it is a lot more likely that someone would pass f(foo) or f(obj.foo) where foo might be undefined.


> Expecting undefined as a possible valid argument (as opposed to a missing argument) seems like a very rare case, and probably a code smell.


> I think it would be very unintuitive to the majority of JavaScript developers, and greatly undermines the usefulness of default parameters for the sake of a minority use case.

Preach it.

> In those cases where undefined is an acceptable parameter, just don't use default parameters.

+9001, as rwaldron likes to say (big fan of ISO?)


More information about the es-discuss mailing list