expression vs statement javascript code example
Example 1: expression vs statement javascript
An expression is any valid unit of code that resolves to a value.
An statement is any valid unit of code that resolves to an instruction.
Wherever JavaScript expects a statement, you can also write an expression.
The reverse does not hold.
Example 2: javascript expression
// EXPRESSION: Code that produces a value
// example(s):
3 + 4
1991
true && false && false
// STATEMENT: Code that performs actions (generally something that ends in ";"
// example:
const str = `String assigned to str`;