JS Statements

Definition and Structure

Statements are individual instructions that JavaScript executes. Each statement ends with a semicolon.

Types of Statements

  • Declaration statements: let x = 5;
  • Expression statements: x + y;
  • Control flow statements: if, for, while

Examples

Example:

let x = 10;
if (x > 5) {
  x++;
}
for (let i = 0; i < x; i++) {
  console.log(i);
}