Labs ICT
โญ Pro Login

Syntax

JavaScript Syntax โ€” The Rules of the Language

Every language has rules. JavaScript's syntax determines how you write statements, expressions, and structure your code. Once you learn the patterns, you'll read and write JS with confidence.

Statements are instructions the computer executes. Expressions are pieces of code that produce values. Semicolons terminate statements (though JavaScript's ASI often inserts them for you).

Basic Statement

console.log("This is a statement.");
Try it Yourself โ†’

Variable Declaration

let age = 25;
const name = "Alice";
Try it Yourself โ†’

Expression as Statement

5 + 3;
"hello".toUpperCase();
Try it Yourself โ†’

Block Statement

{
  let x = 10;
  console.log(x);
}
Try it Yourself โ†’

Conditional Statement

if (5 > 3) {
  console.log("Five is greater than three");
}
Try it Yourself โ†’

Loop Statement

for (let i = 0; i < 3; i++) {
  console.log("Count:", i);
}
Try it Yourself โ†’

Template Literal Expression

const name = "Alice";
console.log(`Hello, ${name}!`);
Try it Yourself โ†’

Destructuring Expression

const point = [10, 20];
const [x, y] = point;
console.log(x, y);
Try it Yourself โ†’

๐Ÿงช Quick Quiz

How do you end a JavaScript statement?