Statement
In one line
A statement is a single instruction that the computer executes, like assigning a variable or calling a function.
In simple words
A statement is a complete instruction that tells the computer to do something. It is the smallest standalone unit of executable code. let x = 5; is a statement — it declares a variable and assigns a value. console.log("hi"); is a statement — it prints text.
Statements are the building blocks of a program. A program is a sequence of statements executed one after another. Each statement typically ends with a semicolon (;) in JavaScript, C, and Java, or a newline in Python.
Common types of statements include: assignment (x = 5), conditional (if (x > 0) {...}), loop (for (...) {...}), declaration (let y), and return (return result). Some statements contain expressions (like x = 2 + 3), but not all expressions are statements.
Example
let x = 5; // declaration + assignment statement
if (x > 0) { // conditional statement
console.log("positive"); // expression statement
}
for (let i = 0; i < 3; i++) { // loop statement
console.log(i);
}Each line is a statement. The program executes them in order: declare x, check condition, loop.
Related terms
Related Resources
Related Lessons
- How Programs Work
Learn about statements and execution.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.