On Wed, Sep 20, 2017 at 11:28 AM, Naveen Chawla <[email protected]>
wrote:
>
> The comma operator seems to make the `do` concept redundant, at
> least for me.
No, not at all. Again: With the comma operator, you can't use *statements*,
only expressions. With the `do` expression, you can use actual statements:
```js
const x = do {
for (const x of getTheThings()) {
if (x.id == something) {
x.foo;
}
}
};
```
...which is basically:
```js
const x = getTheThings().find(x => x.id == something).foo;
```
...except it doesn't throw if `find` returns `undefined`, and isn't a
series of function calls.
`do` expressions are basically to address overly-complex conditional
expressions and IIFEs.
More: https://gist.github.com/dherman/1c97dfb25179fa34a41b5fff040f9879
-- T.J. Crowder
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss