Hacker News new | past | comments | ask | show | jobs | submit login

Actually the problem with automatic semicolon insertion (ASI) is the opposite: It sometimes doesn't insert one where you expect it. ASI only inserts a semicolon when not inserting it would give a syntax error. It's the cases where a newline was really intended to end a statement, but doesn't, the bites you. Example ()creating a generator: var gen = null (function() { var ctr = 0; gen = function() { return ctr++; }; })(); Seems simple, but actually tries to call null as a function.

Also, the + operator doesn't treat all non-numbers as strings. It tries to treat all non-strings as numbers, if possible. Only if that fails does it try them as strings. If either argument is then a string, it does concatenation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: