Extensible destructuring proposal

Samuel Hapák samuel.hapak at vacuumapps.com
Tue Jul 21 15:08:42 UTC 2015


> On 21.7.2015, at 12:42, Claude Pache <claude.pache at gmail.com> wrote:
> 
> For example, one can imagine something like:
> 
> ```js
>    const {author: {name: {first, last}, birthdate}} = book.toObject()
> ```

There are two issues I see here:
- `book.toObject()` would have to do deep conversion and you may not want it. Let’s say birthdate is immutable map `{day, month, year}`*. This would convert `birthdate` to `Object` even though you didn’t want that.

- this can handle only String keys. My proposal could be extended so this would work:

```js
   const {[someNonStringKey]: value} = someMap;
```
We already have a syntax for that in es6.

PS: * I know we have `Date()` for that purpose. Just for demonstration.

Samuel






-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3589 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150721/dcfd85b4/attachment.p7s>


More information about the es-discuss mailing list