A statement is a line of code that performs some action.
for are statements; they perform actions or control actions but don’t resolve to values.
x = 5; is a statement because its effect is assignment (it is changing
Although semicolons are automatically inserted where needed thanks to automatic semicolon insertion (ASI), it’s still considered good practice to insert a semicolon at the end of a statement (except for
while statements, where they are not needed). The documentation for Douglas Crockford’s code quality tool JSLint states:
An expression produces a value. All expressions are also considered statements (whose effect is to evaluate the expression while ignoring the resulting value).
You cannot provide a statement where an expression is expected — for instance, passing an if statement as an argument of a function.
newDate(); (produces an object)
[1, 2, 3] (produces an array object)
5 + 6 (evaluates to the value of 11)
And there you have it! Statements (which are often not expressions) do something, while expressions are statements whose action is resolving to a value.