3 ms·
My understanding is that the original decision was to make life easier for the programmer: if you forget, we'll put one in there for you. Myself, I'd rather be
by a3n 11y ago
My understanding is that the original decision was to make life easier for the programmer: if you forget, we'll put one in there for you. Myself, I'd rather be told that I made a mistake, then have it ignored, because how does the compiler know what I really wanted?
Here's a good one: http://stackoverflow.com/questions/18986144/javascript-compile-error http://stackoverflow.com/questions/18986144/javascript-compi...
Instead of being told there's some problem with the code, it inserts a semi-colon into an arguably ludicrous location, and then gives you a differen error.
Would probably make compiler writers' jobs easier if they just spit out errors.
- ricardobeat 11y agoThe actual reason that third function compiles, and the fourth does not, is that { x: 0 } is a block statement with a label x. Try it in your console, it returns 0. The last one is an object literal outside an expression, which is a syntax error. In addition to that, the return statement is 'restricted production' where the line break itself is a terminator, this has nothing to do with semi-colons or ASI.
- ohitsdom 11y ago> Would probably make compiler writers' jobs easier if they just spit out errors. If this is your preference, JSLint has you covered. Really, every JS developer should be using a linter and tweak it to fit their coding preferences.