News for hackers. Stuff that matters.
Re:Javascript and semicolon insertion by orangecat on Saturday May 29, 2010 @06:40PM (#1389400)
A horrible Javascript misfeature, second only to default global scope. I always use semicolons, but as the article notes even if you do that you still have to be aware of how automatic insertion works.
Re:Javascript and semicolon insertion by notauser on Sunday May 30, 2010 @03:29AM (#1390177)
From the article, the only really nasty things are:

  [a].forEach(fn(){})
  [b].forEach(fn(){})
  // Parses as [a][b]

  return
  a+b
  // Parses as return;
You would have to work pretty hard to trigger the rest.

I'm curious about the speed trade offs from removing semicolons. You shrink the source code a little, but does the parser throwing exceptions all the time bump up execution time?

Re:Javascript and semicolon insertion by barrkel on Sunday May 30, 2010 @01:39PM (#1390807)
A parser would not normally handle this kind of thing with exceptions, and any cost would only be paid once, at parse time when building a syntax tree, not at execution time. Very few languages interpret text directly, rather than interpreting trees, as the trees are far easier to work with, more efficient, etc.