News for hackers. Stuff that matters.
Re:Why I sometimes hate JavaScript by dukky on Friday February 27, 2015 @08:50AM (#9118778)
I really don't see why this isn't a syntax error

What is actually being done with the calls after the chain of +'s?

Edit: Something to do with semicolons being optional in js?

Re:Why I sometimes hate JavaScript by d4n3 on Friday February 27, 2015 @08:59AM (#9118824)
Javascript has "semicolon insertion".

It tries to parse a newline with no semicolon as continuing the current expression, if it can't, it inserts a semicolon.

It's a 'feature' that's caused too many bugs and is a warning in most linters.

Re:Why I sometimes hate JavaScript by afandian on Friday February 27, 2015 @08:56AM (#9118812)
This is valid JS:

    1;
    2;
    alert("returns undefined");
    confirm("return true or false?")
    (function() {return 3})();
    (function() {})();
What's being done with the values of 1, 2, undefined, true/false, 3 and undefined? Nothing if they're not assigned. But as every function returns a value and invocations are therefore an expression, it would be impossible to disallow expressions to be evaluated but not assigned.