Extensible destructuring proposal
Domenic Denicola
d at domenic.me
Tue Jul 21 15:19:58 UTC 2015
From: Samuel Hapák [mailto:samuel.hapak at vacuumapps.com]
> Could you please explain it on example?
>
> Let’s say I have
>
> ```
> let book = Map{author: {name: “John”, surname: “Doe”}, birthdate: “10-10-1990”};
> ```
>
> How would you extract `birthdate`? How would you extract `name`?
Your syntax here is invalid in at least four different ways. Let's assume you wrote something with valid syntax, like
```js
let book = new Map([["author", { name: "John", surname: "Doe" }], ["birthdate", "10-10-1990"]]);
```
Then:
```js
const [[, { name }], [, birthdate]] = book.entries();
```
If this is still confusing, you may wish to turn to StackOverflow for clarification, instead of es-discuss. You can test such things in Firefox, although you need to use `var` instead of `const` or `let`.
More information about the es-discuss
mailing list