tc39 / proposal-extractors

Extractors for ECMAScript
http://tc39.es/proposal-extractors/
MIT License
200 stars 3 forks source link

[] for array bindings instead of ()? #8

Closed tolmasky closed 1 year ago

tolmasky commented 1 year ago

I'm just curious why () was chosen instead of [] for array binding patterns:

Foo[y] = x;

vs.

Foo(y) = x;
rbuckton commented 1 year ago

I'm just curious why () was chosen instead of [] for array binding patterns:

Foo[y] = x;

vs.

Foo(y) = x;

The syntax Foo[y] = x is already valid and meaningful JavaScript and thus can't be used for this. () was chosen because a call expression isn't a valid assignment target and will always throw when assigned to today.

tolmasky commented 1 year ago

Ah yes, I think I was only looking at the Declarations and not the Assignments. Thanks!