JavaScript Automatic Semicolon Insertion - ASI Statements affected by automatic semicolon insertion

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

  • empty statement
  • var statement
  • expression statement
  • do-while statement
  • continue statement
  • break statement
  • return statement
  • throw statement

Examples:

When the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream as a single complete Program, then a semicolon is automatically inserted at the end of the input stream.

a = b
++c
// is transformed to:
a = b;
++c;
x
++
y
// is transformed to:
x;
++y;

Array indexing/literals

console.log("Hello, World")
[1,2,3].join()
// is transformed to:
console.log("Hello, World")[(1, 2, 3)].join();

Return statement:

return 
  "something";
// is transformed to
return;
  "something";


Got any JavaScript Question?