The Unary Plus Operator (+)
Description
The Unari Plus Operator (+) returns the numeric value of its operand.
The unary plus operator attempts to convert its operand to a number.
- Strings ("123") are converted to their numeric equivalent (123).
- Boolean values (true, false) are converted to 1 and 0.
- null is converted to 0.
- undefined and non-numeric variables are converted to NaN (Not a Number).
The Unary Plus Operator has higher precedence than operations like multiplication or subtraction, so it is evaluated first
Learn More:
Browser Support
Unary Plus
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera |