Proposal: syntactic sugar for extracting fields from objects

Bob Myers rtm at gol.com
Wed May 29 18:02:36 UTC 2019


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/37629dbe/attachment.html>


More information about the es-discuss mailing list