Monday, December 8, 2025
HomeLanguagesJavascriptJavaScript Arithmetic Unary Plus(+) Operator

JavaScript Arithmetic Unary Plus(+) Operator

The Unary plus(+) operation is a single operand operator (which means it worked with only a single operand preceding or succeeding to it), which is used to convert its operand to a number, if it isn’t already a number. 

Syntax:

+Operand

Below examples illustrate the Unary plus(+) Operator in JavaScript:

Example 1:This example shows the use of the JavaScript Unary plus(+) Operator. It converts a string into a number.

Javascript




const x = "10";
let y;
y = +x;
console.log(y);
console.log(typeof y);


Output:

10
number

Example 2: The following example demonstrates a unary method with numbers.

Javascript




const a = 100;
const b = -100;
const c = 20;
  
console.log(+a);
console.log(+b);
console.log(+c);


Output:

 100
-100
 20

Example 3: The following example demonstrates a unary method with non-numbers.

Javascript




const a = true;
const b = false;
const c = null;
const d = function (x) {
    return x
};
  
console.log(+a);
console.log(+b);
console.log(+c);
console.log(+d);


Output:

1
0
0
NaN

We have a complete list of Javascript Operators, to check those please go through the Javascript Operators Complete Reference article.

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Safari
  • IE
  • Opera
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32429 POSTS0 COMMENTS
Milvus
103 POSTS0 COMMENTS
Nango Kala
6803 POSTS0 COMMENTS
Nicole Veronica
11945 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12015 POSTS0 COMMENTS
Shaida Kate Naidoo
6934 POSTS0 COMMENTS
Ted Musemwa
7189 POSTS0 COMMENTS
Thapelo Manthata
6883 POSTS0 COMMENTS
Umr Jansen
6869 POSTS0 COMMENTS