Extending object literal property value shorthand

Rick Waldron waldron.rick at gmail.com
Wed Mar 25 13:55:37 UTC 2015


Inline...

On Wed, Mar 25, 2015 at 12:25 AM Bob Myers <rtm at gol.com> wrote:

> Thanks Rick. Yes, I had been hoping to make the following work:
>
> x = {a: 1};
> y = {b: 2};
> z = {x.a, b.y}; // {a: 1, b: 2}
>
> This is not destructuring per se.
>

Of course, and that's not what I was exploring in attempting to extend
12.2.5.9 Runtime Semantics: PropertyDefinitionEvaluation


> It's an extension to object literal property value shorthand syntax.
> The idea was to derive the desired property name `a` from `x.a`.
> This seems compact and readable.
>


> However, as you found it could be difficult to define when and how a
> property name could be derived from various types of member expressions.
>

After more thought, I think it can be done with a set of explicit early
errors that disallow a subset of MemberExpression nonterminals.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150325/ad7d75ca/attachment.html>


More information about the es-discuss mailing list