Unary operators are those that operate on a single value or expression result.
Some of the unary operators use keywords to convey their meaning. Others are sequences of punctuation characters. Here are the unary operators defined by ECMAScript:
Operator | Meaning |
---|---|
+ | Convert the operand to a numeric value. |
++ | Increment the numeric value of the operand. |
- | Convert the operand to a numeric value and negate it. |
-- | Decrement the numeric value of the operand. |
~ | Convert the operand to a 32 bit integer and perform a bitwise complement on it. |
! | Convert the operand to a boolean value and reverse its value. |
new | Invokes an object constructor |
delete | Used to delete a property from an object if it can be deleted. |
void | Regardless of the result of evaluating the expression that may be operated on, this will always yield the undefined value. |
Some of these operators have a different meaning when used with more than one operand.
ECMA 262 edition 2 - section - 11.4
ECMA 262 edition 3 - section - 11.4
Wrox Instant JavaScript - page - 19
Prev | Home | Next |
Unary expression | Up | undefined |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |