I disagree that this is something that doesn't happen often. 

var a = {
    { b, c, d, e } = B
};

I believe that this would be more consistent with the object destructoring 
since it now uses the = sign and looks like it encapsulates a descructure with 
{} which is like how the shorthand works

Sebastian Malton


  Original Message  
From: [email protected]
Sent: March 16, 2018 5:26 PM
To: [email protected]
Cc: [email protected]
Subject: Re: Expanding Object Shorthand

On Fri, Mar 16, 2018 at 1:58 PM, Sebastian Malton <[email protected]> wrote:
> Yes that is possible but what if you want to do the following?
>
> ```
> var a = {
>     b: B.b,
>     c: B.c,
>     d: B.d,
>     e: B.e
> };
> ```
>
> Would it not be easier to do the following?
>
> ```
> var a = {
>     { b, c, d, e }: B
> };
> ```

It's shorter to write, sure. But we can come up with special-purpose
ways to shorten code all day.

This proposal is not consistent with the existing shorthand syntax, or
the object-destructuring syntax it also somewhat resembles. It's
unique, while looking very similar to existing syntax, and for a
relatively small case (extracting a subset of the properties of an
object into another object, with the same key names).  That's usually
not a recipe for success. :(

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to