JavaScript statements are the individual instructions that the browser executes, one after another. A JavaScript program (or script) is simply a collection of these statements.
;) for clarity and safety.{ }.if, for, let that define actions.In JavaScript, most lines you write are statements. They typically follow this pattern:
let, const, or var.x + y.console.log(sum).if, for, while, which often use blocks.A block is written using curly braces { } and can contain one or more statements. Blocks are used with functions, loops, and conditionals to group related logic.
JavaScript also has many keywords, which are special reserved words with predefined meaning (you cannot use them as variable names).
This example shows simple variable declarations, an expression, and a function call as separate statements.
let x = 5;
let y = 10;
let sum = x + y;
console.log(sum);
A block groups multiple statements together inside curly braces { }. All statements in the block execute together in order.
{
let a = 10;
let b = 20;
console.log(a + b);
}
You can put multiple statements on the same line separated by semicolons, but it usually hurts readability.
let x = 5; let y = 6; console.log(x + y);
sum is 5 + 10, so the console shows: 15.a + b is 10 + 20, so the console shows: 30.x + y is 5 + 6, so the console shows: 11.All of these outputs appear in the browser’s JavaScript console, which you can open using the developer tools.
Keywords are special words that tell JavaScript what kind of statement you are writing. Some commonly used ones include:
var, let, constif, else, switchfor, while, dofunction, returnBecause these words have predefined meanings, you should never use them as variable or function names.
{ } to group related logic, especially in conditionals and loops.let or const (or var in older code) to avoid creating accidental global variables.if statement with a block that runs only when a condition is true (for example, when a number is greater than 10).