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

Semicolon insertion in Javascript is nothing like braces.

The grammar for e.g. an if statement is simple: *if (* expression *)* statement *else* statement. One particular value of statement is a block statement, which is where the braces come from. Nothing more, nothing less.

Inversely, the grammar specifically says that most statements (of types empty, expression, do-while, continue, break, return, throw, and debugger) must end with a semicolon, and ASI is explicitly described as a few cases where you're allowed to add an extra token to the token stream when the grammar refuses to accept the stream as-is.




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

Search: