Object arithmetic--operator alternative to Object.assign

Tab Atkins Jr. jackalmage at gmail.com
Tue Mar 24 19:51:30 UTC 2015

On Tue, Mar 24, 2015 at 9:44 AM, Bob Myers <rtm at gol.com> wrote:
> Apologies if something like this has already been proposed.
> We have simplified object literal syntax:
> {a, b}
> However, I often find myself writing this:
> {a: x.a, b: y.b}
> Would it be possible to have a syntax such as
> {x.a, y.b}
> Where the property name is taken from the last segment of the property
> reference, so that `x.a` becomes the value of property `a`?

If you're taking both values from the *same* object, we have the syntax:

{a, b} = x;

This may or may not help you.


More information about the es-discuss mailing list