Skip to content

Comment on Semicolons in JavaScript are optional

Comments

FWIW If you're using JavaScript in PhotoShop the following produces an error because there's no semicolon after the second statement:

  for(i=10;i--) { /* do stuff */ }
So maybe that's an example of a JS implementation where it differs on optional semicolons.

That doesn't work in any javascript interpreter. Semi-colons aren't optional inside the parenthesis of a for statement, according to the spec.

http://www.ecma-international.org/publications/files/ECMA-ST...

Section 7.9.2 (page 37)

Doh. Yes.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.