Destructuring an object into a new object (like Underscore pick but ESier)
Bob Myers
rtm at gol.com
Mon Feb 22 04:20:22 UTC 2016
In my proposal, there are two syntaxes related to "deep" or "nested"
picking.
Assuming:
```js
var obj = {a: {b: 1, c: 2}, d: 3};
```
Inside the picking construct, the dot does a "deep pick":
```
obj.{a.b} // { b: 1 }
```
The colon does a "nested pick":
```
obj.{a: {b}} // { a: {b: 1}}
```
Bob
On Mon, Feb 22, 2016 at 6:16 AM, Bergi <a.d.bergi at web.de> wrote:
> Viktor Kronvall schrieb:
>
>> What would this do?
>> ```
>> let newObj = {obj.a.b}
>> ```
>>
>> `{a: {b: obj.a.b}}`
>> or
>> `{a: obj.a.b}`?
>>
>> Or should nested property access be disallowed?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160222/d16d4f46/attachment.html>
More information about the es-discuss
mailing list