Favorites

JavaScript +x Unary plus Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
+x
JavaScript Unary OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The unary plus operator (+) placed before a value converts it to a number. It's a short alternative to Number().

Description

The unary plus operator +, placed before a single operand, converts it to a number, just like Number(value). +'42' is 42, +true is 1, +'' is 0 and +'abc' is NaN. It can't convert BigInts and throws a TypeError if you try. Number() is more readable when the intent isn't obvious.

Unary plus has a high precedence, so in an expression like +a + +b each operand is converted before they're added together, which is a quick way to add two numeric strings. Applied to a Date, it returns the timestamp, +new Date(), although Date.now() is clearer for the current time.

Its conversion rules are strict: the whole string must be a valid number (with surrounding white space ignored), so +'12px' is NaN. Use parseInt() or parseFloat() when a string starts with a number followed by other text, such as CSS values.

Properties

Operator
+x
Category
Unary
Precedence
14 (1 is lowest, 18 is highest)
Associativity
right-to-left

Syntax

+x

Example

console.log(+'42', +'3.5', +'');
console.log(+true, +null, +undefined);
console.log(+'12px');
const a = '5', b = '10';
console.log(+a + +b);

Browser Support

The following information will show you the current browser support for the +x operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee