Proposal: result-forwarding ternary operator

T.J. Crowder tj.crowder at
Wed Sep 20 10:41:37 UTC 2017

On Wed, Sep 20, 2017 at 11:28 AM, Naveen Chawla <naveen.chwl at>
> 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:

const x = do {
    for (const x of getTheThings()) {
        if ( == something) {

...which is basically:

const x = getTheThings().find(x => == 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.

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list