Expression (Definition)

Combining one or more operands with an operator creates an expression.


ECMAScript edition - 2

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 are the contexts within which JavaScript operates on entities in its object model. There are a variety of different kinds of expressions according to whether you are referring to the destination or source of an assignment or reference.

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:

PrimaryA 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-SideThis kind of expression identified the destination of an assignment (even if that assignment operation is only implied).
PostfixPostfix expressions operate on Left-Hand-Side (sometimes called LValue) expressions.
UnaryUnary expressions can also be considered to be prefix expressions and also operate on LValues.
MultiplicativeMultiplicative expressions use the multiplicative operators to yield a result by operating on two other values which may themselves be nested.
AdditiveAdditive expressions use the additive operators to yield a result by operating on two other values which may be nested expressions.
ShiftShifts the left value by an amount specified by the right value.
RelationalRelational expressions yield a Boolean result according to the relational test of the values either size of the operator.
BitwiseBitwise expressions perform a bit by bit operation across the entire integer width of the values.
LogicalLogical operators perform a test of the Boolean value of the two operands either side of the operator.
ConditionalConditional expressions test a logical expression and perform one of two possible alternative code blocks.
AssignmentAssignment expressions can be broken down into a two-operand expression with the result being assigned to the value on the left.
CommaComma 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.

See also:Associativity, Bit-field, Exception, JavaScript language, Side effect


ECMA 262 edition 2 - section - 11

ECMA 262 edition 3 - section - 11