Extended dot notation (pick notation) proposal

Jonathan Bond-Caron jbondc at gdesolutions.com
Thu Sep 22 15:37:56 UTC 2016


On Tue Sep 20 03:38 PM, Bob Myers wrote:
> 
> People in the real world continue to wonder why they can't 
> pick/destructure from objects into objects, instead of just variables.
> 
> http://stackoverflow.com/questions/39602360/es6-destructuring-reassign
> ment-of-object?noredirect=1#39602360 

Seems like allowing to "dot" into another identifier could work:
https://tc39.github.io/ecma262/#prod-CoverInitializedName

CoverInitializedName[Yield]:
  IdentifierReference[?Yield]  Initializer[+In, ?Yield]
  IdentifierReference[?Yield]  . IdentifierName

const IDENTIFIER = 1;
const sandwichesIWantToEat = { SANDWICHES.CHEESE_STEAK, SANDWICHES.SLOPPY_JOE, IDENTIFIER };

Use the RHS identifier as the member/property name and resolve the "dot" expression to get the value.

const sandwichesIWantToEatResult = { CHEESE_STEAK: SANDWICHES.CHEESE_STEAK, SLOPPY_JOE: SANDWICHES.SLOPPY_JOE, IDENTIFIER: IDENTIFIER };



More information about the es-discuss mailing list