Subtract (-) (Operator/additive)

Subtracts the right operand from the left operand.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera browser - 3.0
Property/method value type:Number primitive
JavaScript syntax:-anOperand1 - anOperand2
Argument list:anOperand1A numeric value to be subtracted from
anOperand2A numeric value to be subtracted

Subtraction is indicated when two operands are separated by a minus sign.

The value on the right is subtracted from the value on the left. The result is the difference between the two values.

Subtraction behaves identically to addition, as if the formula:

a - b

had become:

a + (-b)

The associativity is left to right.

Refer to the operator precedence topic for details of execution order.

See also:Add (+), Additive operator, Arithmetic operator, Assign value (=), Assignment expression, Associativity, Negation operator (-), Operator Precedence, Subtract then assign (-=)

Cross-references:

ECMA 262 edition 2 - section 11.6.2

ECMA 262 edition 2 - section 11.6.3

ECMA 262 edition 3 - section 11.6.2