Expressions
- produce a value
Statements
- perform an action
- e.g.
if
andloop
statements - end with semicolons
General
- Expressions can be written wherever statements can be written. They are expression statements
var x = 5; // expression statement
x = 5 // expression
- but you cannot write statements where an expression is expected.
if
statements cannot be used as arguments in a function - Anything that can be used as a value is an expression
References
http://2ality.com/2012/09/expressions-vs-statements.html https://stackoverflow.com/questions/12703214/javascript-difference-between-a-statement-and-an-expression