Proposal: syntactic sugar for extracting fields from objects

Григорий Карелин grundiss at gmail.com
Wed May 29 19:15:29 UTC 2019


I agree.

So, what does community think? Do we want to have “destructuring picking”
sugar in JS and if we do, which syntax looks more attractive?

I’d suggest to vote.


On Wed, 29 May 2019 at 21:55, Bob Myers <rtm at gol.com> wrote:

> This syntax merely combines and extends two existing notations:
>
> 1. Dot notation to access properties, which has been in JS since it was
> initially designed, with the RHS extended to permit a *set* of properties
> in `{}` in addition to a plain old identifier as at present.
> 2. Property spread notation (`{...{}}`).
>
> On Wed, May 29, 2019 at 11:27 AM Григорий Карелин <grundiss at gmail.com>
> wrote:
>
>> Well, I guess it might work too.
>>
>> I personally like more verbose constructions, with keywords instead of
>> dots, asterisks, etc :)
>>
>> On Wed, 29 May 2019 at 21:03, Bob Myers <rtm at gol.com> wrote:
>>
>>> On Wed, May 29, 2019 at 10:28 AM Григорий Карелин <grundiss at gmail.com>
>>> wrote:
>>>
>>>> Hi Cyril,
>>>> With the syntax you propose what would be the way to to this:
>>>> ```
>>>> const source = {foo: 1, bar: 2};
>>>> const result = {foo: source.foo, bar: source.bar, buzz: 3}
>>>> ```
>>>> ?
>>>>
>>>
>>> As already mentioned earlier in this thread:
>>>
>>> ```js
>>> const source = {foo: 1, bar: 2};
>>> const result = {...source.{foo, bar}, buzz: 3};
>>> ```
>>>
>> --
>> Отправлено с мобильного устройства
>>
> --
Отправлено с мобильного устройства
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190529/b7635c6d/attachment-0001.html>


More information about the es-discuss mailing list