An expression is a piece of code that resolves to a value.
Consider the following example:
In the above example:
-
20 + 30 is an expression.
+ is the operator.
20 and 30 are operands. It resolved to the value 50.
-
length = 1000 is an expression.
= is the operator.
length and 1000 are operands.
-
length / 100 is an expression.
/ is the operator.
length and 100 are operands.
-
typeof "Hello World" is an expression.
typeof is the operator.
"Hello World" is the operand.
Note that, operators that require two operands are called binary operators.
+, -, *, /, and = are all binary operators.
Operators that require only one operand are called unary operators.
typeof is a unary operator.
The operators +, -, *, and / are called arithmetic operators and are used to perform arithmetic operations on numbers.