1 of 5

SHORTHAND PROPERTY IMPROVEMENTS

Ron Buckton – Microsoft Corporation

2 of 5

PROPOSAL

  • Property Access in object initializers
  • Property Access in destructuring assignments

// object initializer, dot-notation

const a = { o.x };

// object initializer, bracket-notation

const a = { o["x"] };

// destructuring, dot-notation

({ a.x } = o);

// destructuring, bracket-notation

({ a["x"] } = o);

3 of 5

SEMANTICS

  • Object initializers
    • {o.x} is identical to {x: o.x}
    • {o["x"]} is (roughly) identical to {["x"]: o["x"]}
  • Destructuring Assignment
    • ({a.x} = o) is identical to ({x: a.x} = o}
    • ({a["x"] } = o) is (roughly) identical to ({["x"]: a["x"]} = o)
  • Actual implementations would use GetReferencedName

4 of 5

GRAMMAR

PropertyDefinition[Yield, Await] :

MemberExpression[?Yield, ?Await] . IdentifierName

MemberExpression[?Yield, ?Await] [ Expression ]

CallExpression[?Yield, ?Await] . IdentifierName

CallExpression[?Yield, ?Await] [ Expression ]

AssignmentProperty[Yield, Await] :

MemberExpression[?Yield, ?Await] . IdentifierName Initializer[+In, ?Yield, ?Await]opt

MemberExpression[?Yield, ?Await] [ Expression ] Initializer[+In, ?Yield, ?Await]opt

CallExpression[?Yield, ?Await] . IdentifierName Initializer[+In, ?Yield, ?Await]opt

CallExpression[?Yield, ?Await] [ Expression ] Initializer[+In, ?Yield, ?Await]opt

5 of 5

STATUS

  • Stage: 0
  • Identified Champions: Ron Buckton
  • Strawman available