destructuring in formal parameters?

Brendan Eich brendan at mozilla.com
Thu Nov 13 15:29:00 PST 2008


On Nov 13, 2008, at 2:57 PM, Peter Michaux wrote:

> With destructuring this could be reduced to
>
> function f(params) {
>  var {foo, bar} = params;
>  //...
> }
>
> f({foo:1, bar:2});
>
> Could it be reduced even further to the following syntax?
>
> function f({foo, bar}) {
>  //...
> }
>
> f({foo:1, bar:2});

This was in the ES4 proposal, and it's implemented in Firefox 3 /  
JavaScript1.8:

js> function f({foo, bar}) { return [foo, bar]; }
js> f({foo:1, bar:2});
1,2

IIRC formal parameter destructuring was Harmonious when I presented it  
in July.

/be


More information about the Es-discuss mailing list