Question of destructuring

Eric Suen eric.suen.tech at gmail.com
Sat Nov 8 09:40:27 PST 2008


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?

Regards,

Eric Suen




More information about the Es-discuss mailing list