(x) => {foo: bar}

Isiah Meadows impinball at gmail.com
Mon Jan 5 23:18:18 PST 2015

> From: Alex Kocharin <alex at kocharin.ru>
> To: Gary Guo <nbdd0121 at hotmail.com>, "brendan at mozilla.org" <brendan at mozilla.org>
> Cc: "es-discuss at mozilla.org" <es-discuss at mozilla.org>
> Date: Tue, 06 Jan 2015 06:59:52 +0300
> Subject: Re: (x) => {foo: bar}
> 06.01.2015, 06:38, "Gary Guo" <nbdd0121 at hotmail.com>:
> Though I am strongly negative, but there actually is such an implementation. The REPL of node will parse {a:1} as object literal while {a:1;} as block.
> Node.js REPL wraps all the statements in parentheses. Therefore `{a:1;}` becomes `({a:1;})` which is a syntax error.

Not in my REPL (node 0.10.33).

$ node
> {a:1;}
> {a:1}
{ a: 1 }

What the Node.js REPL effectively appears to do, AFAICT, is some sort
of evented try-catch. Though, @Gary, I agree 100% with what you said
about being very against it. It would require a lot more context to
figure out if something returns an object, as `{a, b, c}` is
technically both a valid block and object (using shorthand
properties). The problems would then become non-obvious and difficult
to diagnose in practice.

Isiah Meadows

More information about the es-discuss mailing list