Negation operator (-) (Operator/unary)

Negate an operand's value.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:--anOperand
Argument list:anOperandA numeric value that can be negated

The operand is evaluated and converted to a numeric value. The result is negated.

A positive value becomes negative and a negative value becomes positive.

This is functionally equivalent to:

anOperand *= -1

Which is equivalent to:

anOperand = anOperand * -1

And also:

anOperand = 0 - anOperand

Although this is classified as a unary operator, its functionality is really that of an additive operator.

The associativity is from right to left.

Refer to the Operator Precedence topic for details of execution order.

See also:Add (+), Additive expression, Additive operator, Associativity, Decrement value (--), Operator Precedence, Subtract (-), Unary operator

Cross-references:

ECMA 262 edition 2 - section - 11.4.7

ECMA 262 edition 3 - section - 11.4.7