JavaScript Unary Operator | JavaScript Unary Operator Tutorial By WDH

JavaScript Unary Operators


JavaScript Unary Operators
Unary operators are the operators which requires only one operand. While a binary operator requires and tertiary requires three operands.
The Unary Operators are as shown below:
Operator
Description
+
Converts its operands to umber type
-
Converts its operands to umber type negates it
++exp
Increment the value by one and store it back in variable. Returns new incremented value 
--exp
Decrement the value by one and store it back in variable. Return new decrement value 
exp++
Return the old value. Increment the value by one and store it back in variable.
exp--
Returns the old value. Decrement the value by one and store it back in the variable.
Example
Output
Unary Operators
28
22
21
21
22