Question · JavaScript and TypeScript course · Module 1: JavaScript Basics

Semicolon Optionality in JavaScript

Is the semicolon at the end of a statement mandatory in JavaScript?

Answer options

  • Semicolons are outdated and should not be used
  • Yes, the code will not work without a semicolon
  • No, but it is recommended - JavaScript has the ASI mechanism
  • Semicolons are required only in loops
Show the answer

Correct answer:

  • No, but it is recommended - JavaScript has the ASI mechanism