Object arithmetic--operator alternative to Object.assign

Bob Myers rtm at gol.com
Tue Mar 24 16:44:50 UTC 2015


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`?

--
Bob

On Wed, Mar 11, 2015 at 9:26 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>
wrote:

>
> On Mar 11, 2015, at 7:23 AM, Bergi wrote:
>
> Bob Myers schrieb:
>
> Apologies if something like this has already been proposed and/or rejected
>
> for whatever reason.
>
>
> I think you're looking for the same as
> http://wiki.ecmascript.org/doku.php?id=strawman:define_properties_operator
>
>
> also see: https://github.com/allenwb/ESideas/blob/master/dcltomethod.md
>
> Allen
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150324/529b14cb/attachment.html>


More information about the es-discuss mailing list