I'm writting my own ES6 parser. But I don't understand what CoverInitializedName is in ObjectLiteral.
In the section about this in the ECMA-2015 ObjectLiteral spec I see
PropertyDefinition[Yield] :
IdentifierReference[?Yield]
CoverInitializedName[?Yield] <-- this is what I dont understand
PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
MethodDefinition[?Yield]
Then I look up the definition of CoverInitializedName.
CoverInitializedName[Yield] :
IdentifierReference[?Yield] Initializer[In, ?Yield]
IdentifierReference[Yield] :
Identifier
[~Yield] yield
Initializer[In, Yield] :
= AssignmentExpression[?In, ?Yield]
Initializer starts with = sign.
Which means I can assign property using assign operator like this.
let o = { prop = value };
If I execute this code it will throw SyntaxError: Invalid shorthand property initializer
I confused and look in the MDN Object initializer docs. There is no such thing. So what is this CoverInitializedName?
[EDIT]
loganfsmyth's answer was
({ prop = value } = {}); // valid destructuring
In this script, the left-hand side { prop = value }
is not an ObjectLiteral
. Which is ObjectBindingPattern assigning default value 13.3.3 Destructuring Binding Patterns. I think ObjectLiteral is rValue isn't it? So my question remains: what is CoverInitializedName in ObjectLiteral? Or did I misunderstand something?