An expression consists of an operand on its own, or a combination of operators and operands. An operand may be a constant value, a functional value, or a variable. Evaluating expressions can easily cause side effects, especially when functions are invoked.
Expressions fall into one of several categories according to the operator used in the expression.
The following expression types are defined in the ECMAScript standard:
|Primary||A Primary Expression is a specific object, identifier or literal and may also be the result of evaluating another nested expression when it is surrounded by the grouping operators (round brackets).|
|Left-Hand-Side||This kind of expression identified the destination of an assignment (even if that assignment operation is only implied).|
|Postfix||Postfix expressions operate on Left-Hand-Side (sometimes called LValue) expressions.|
|Unary||Unary expressions can also be considered to be prefix expressions and also operate on LValues.|
|Multiplicative||Multiplicative expressions use the multiplicative operators to yield a result by operating on two other values which may themselves be nested.|
|Additive||Additive expressions use the additive operators to yield a result by operating on two other values which may be nested expressions.|
|Shift||Shifts the left value by an amount specified by the right value.|
|Relational||Relational expressions yield a Boolean result according to the relational test of the values either size of the operator.|
|Bitwise||Bitwise expressions perform a bit by bit operation across the entire integer width of the values.|
|Logical||Logical operators perform a test of the Boolean value of the two operands either side of the operator.|
|Conditional||Conditional expressions test a logical expression and perform one of two possible alternative code blocks.|
|Assignment||Assignment expressions can be broken down into a two-operand expression with the result being assigned to the value on the left.|
|Comma||Comma expressions occur rarely and are used to evaluate several expressions at once.|
The operators are discussed in detail in individual topics. Refer to those topics for more details.
Expressions resolve eventually to a primary expression, which has a distinct value.
In a compound expression, the precedence (or "Who's on first") is governed by the operator-selected for that sub-expression. However that operator-driven precedence model can be overridden by use of the grouping operators.