Open In App

JavaScript Addition (+) Operator

Last Updated : 19 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

JavaScript addition (+) operator is one of the most fundamental and widely used arithmetic operators in JavaScript. It is used to perform arithmetic addition on numbers but also concatenate strings.

Syntax

a + b

Where –

  • a: The first value (number, string, or another data type).
  • b: The second value (number, string, or another data type).

Return Type: It returns the sum/concatenation of numbers/strings.

Example 1: In this example, we will use the addition operator on some primitive data types and check their equivalent sum.

console.log(1 + 2);
console.log(NaN + 1);
console.log(true + 1);
console.log(false + 1);

Output
3
NaN
2
1

Example 2: In this example, we will use the addition operator to perform concatenation

console.log("1" + 2);
console.log("Hello " + "Geek");

Output
12
Hello Geek

Supported Browser

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 3
  • Safari 1

We have a complete list of Javascript Arithmetic operators, to check those please go through this JavaScript Arithmetic Operators article.


Article Tags :

Similar Reads

three90RightbarBannerImg