"Exception: parameter(s) with default followed by parameter without default"

Keith Cirkel es-discuss at keithcirkel.co.uk
Wed Oct 10 06:21:34 PDT 2012


You /are/ actually passing in a second argument though, your second
argument is `undefined`. Default arguments aren't meant to replace
`undefined` values, they're meant to be permissible for omission.
--
Keith Cirkel



On 10 October 2012 14:19, David Bruant <bruant.d at gmail.com> wrote:

> Hi,
>
> I've tried the following on Firefox:
>
>   function f(a, b = 34, c){
>       console.log('b', b)
>   }
>
>   f(1, undefined, 43)
>
> and got "Exception: parameter(s) with default followed by parameter
> without default"
> It seems intentional, but I wonder why it's been decided this way.
>
> It seems that default values for parameters "in the middle" can be useful
> for older code base where parameters haven't been organized in prevision of
> default value without requiring a refactoring involving switching parameter
> order for all calls.
>
> David
>
> function f(a, b = 34, c){
>
>
>
>
>     console.log('b', b)
> }
>
> f(1, undefined, 43)
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121010/9ed0accf/attachment.html>


More information about the es-discuss mailing list