Proposal: named and bound deconstructions

Bob Myers rtm at gol.com
Thu Jan 25 05:53:49 UTC 2018


> Destructuring made it possible to flatten 3-5 lines to 1, along with the
ability to provide defaults.

Yet, as an aside, this "principle" of "flattening" being a sufficient or at
least necessary condition for syntax proposals, is itself not applied
consistently, as seen in the "rejection" (if lack of positive response on
this mailing list can be deemed "rejection") of the proposed
property-picking syntax, which allows one to replace three lines

```
const {a, b} = foo;
const {c, d} = bar;
return {a, b, c, d};
```

with one:

```
return { {a, b} = foo, {c, d} = bar };
```

Actually, by the way, destructuring is of course about more than brevity.
It mitigates a common type of typo-related bug:

```
const misspelledProp = foo.mispeledProp;
```

Bob


On Thu, Jan 25, 2018 at 10:02 AM, Isiah Meadows <isiahmeadows at gmail.com>
wrote:

> I'm just not convinced it adds anything substantial. Destructuring
> made it possible to flatten 3-5 lines to 1, along with the ability to
> provide defaults. This just:
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180125/d1fc4704/attachment.html>


More information about the es-discuss mailing list