Question of destructuring

Brendan Eich brendan at mozilla.com
Sat Nov 8 19:15:22 PST 2008


On Nov 8, 2008, at 9:40 AM, Eric Suen wrote:

> https://developer.mozilla.org/en/New_in_JavaScript_1.7
>
> has following statement:
>
> for each (let {name: n, family: { father: f } } in people) {
>  print ("Name: " + n + ", Father: " + f + "<br>\n");
> }
>
> But in http://www.ecmascript.org/es4/spec/grammar.pdf
>
> ForInBinding ::= Pattern
>  | VariableDefinitionKind VariableBinding
>
> VariableBinding ::= TypedIdentifier
>  | TypedPattern VariableInitialisation
>
> VariableInitialisation ::= '=' AssignmentExpression
>
> Obviously "let {name: n, family: { father: f } }" is not a Pattern,
> So, how the above statement is valid?

It's a bug, thanks for pointing it out. The ES4 grammar is not being  
maintained now AFAIK. Cc'ing Jeff.

/be



More information about the Es-discuss mailing list