undefined being treated as a missing optional argument

Russell Leggett russell.leggett at gmail.com
Fri Apr 13 09:50:33 PDT 2012

> I'd write it:
>     function fadeToggle(...args){
>         if(visible){
>                 fadeOut(...args);
>         }else{
>                 fadeIn(...args);
>         }
>     }
> If you don't care about the the actual argument values are just passing
> them on that's how you should do it.

Ok, sure, but in an equally likely case, only one of the arguments is a
pass through, should you still use ...args for one thing just to
distinguish? What about other case like objects with optional properties

I just don't understand why someone who wanted to be able to distinguish
between missing and undefined would really need the extra convenience of
default parameters. What are they going to default to - undefined?
Meanwhile, the rest of the people that probably could use it all the time
to replace their foo = foo || "default" code have to keep it around. I
understand what you're saying in principle. There is a certain amount of
purity and correctness to it, I just don't think its practical.

- Russ

> Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120413/298ce465/attachment.html>

More information about the es-discuss mailing list