Default argument values

Brendan Eich brendan at
Wed Feb 27 18:47:26 PST 2008

On Feb 27, 2008, at 6:35 PM, Steven Mascaro wrote:

>>  This is not to knock named parameters, just to explain why they  
>> never
>>  made it into a serious proposal in the modern ES4 era.
> That sounds fine. The only thing it misses is interchanging positional
> and named parameters, but that's no big deal. Will default values work
> by doing the following?
> function foo({option1, crud2, frob} = {option1: 1, crud2: "dirty",
> frob: "enius"}) { ... }

That should work.

> A bit cumbersome, but otherwise OK. I tried in the RI, but it throws a
> ParseError. Though both the following give the same error as well:
> function foo({option1, curd2, frob}) {}
> ({x, y} = {x: 42, y: 37})

That object destructuring shorthand was approved at

but I don't see a ticket, or morph of 111, asking for RI  
implementation. It's not yet implemented:

 >> function f({p:x,q:y}) [x,y];
 >> f({p:1,q:2})
 >> function g({p,q}) [p,q]
**ERROR** ParseError: unknown token in destructuringField (near <no  

but as shown above, the longhand form works, and so do default  

 >> function h({p:x,q:y} = {p:3,q:4}) [x,y]
 >> h()


More information about the Es4-discuss mailing list