Continuing woes in reading the ES6 spec language

Brendan Eich brendan at mozilla.com
Sun Sep 15 16:22:09 PDT 2013


Oliver Hunt wrote:
>> function foo(x, y = a, z = y) {...}
>> >  
>> >  foo()        // x=undefined, y=a, z=a
>> >  foo(1)       // x=1, y=a, z=a
>> >  foo(1, 2)    // x=1, y=a, z=2???
> Why the ???
>
> This makes sense, and it is what other languages with default values do

What other languages?

Say a = 4 outside. Then

foo(1, 2)

should bind x = 1, y = 2, and z = undefined -- it should not skip y just 
because y has a parameter default value and bind 2 to z.

/be


More information about the es-discuss mailing list