Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The browser somehow detects that the missing semicolon wasn't omitted and doesn't add it???


No. If it's missing it's inserted obviously. That's why you shouldn't omit it.

Here are the rules for parsing if you're interested

When the program contains a token that is not allowed by the formal grammar, then a semicolon is inserted if (a) there is a line break at that point, or (b) the unexpected token was a closing brace.

When the end of a file is reached, if the program cannot be parsed otherwise, then a semicolon is inserted.

When a "restricted production" is encountered and contains a line terminator in a place where the grammar contains the annotation "[no LineTerminator here]", then a semicolon is inserted.




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

Search: