RFE: Allow newline when returning an anonymous object

Tab Atkins Jr. jackalmage at gmail.com
Wed May 28 11:59:51 PDT 2014


On Wed, May 28, 2014 at 11:51 AM, cowwoc <cowwoc at bbs.darktech.org> wrote:
> Wow, what a mess. I've been pretty methodical about semicolons in my code so
> I forgot about this "feature" :)
>
> I'm not a fan of ASI, but in light of your example I agree there is
> ambiguity. Thanks for the clarification.

Remember the general rule: semicolons are always automatically
inserted at the end of lines *unless* doing so would cause a syntax
error on that line or the next.

That's why, for example, you can break method chains across lines on
either side of the period:

foo().bar()
  .baz()

or

foo().bar().
  baz()

because a semicolon between the lines would cause a syntax error in
either.  But blocks/object literals are different, so you need to
start the object literal on the first line.

~TJ


More information about the es-discuss mailing list