Open In App

Increment(+ +) Arithmetic Operator in JavaScript

JavaScript increment(+ +) operator is used to increase the value of the variable by one. The value returned from the operand depends on whether the increment operator was on the left(prefix increment) or right(postfix increment). If the operator is used before the operand then the value is increased by one and then returned but if the operator is after the operand then the value is first returned and then incremented. 

The increment operator can only be used on references that is the operator can only be applied to variable and object properties. Also, the increment operator cannot be chained



Syntax:

a++
OR
++a

Example 1: In this example, we will see the value returned when the increment operator is applied after the operand(postfix increment).






let x = 10;
console.log(x++);
console.log(x);

Output: We can observe that first the value is returned and then incremented.

10
11

Example 2: In this example, we will see the values returned when the operator is applied before the operand(prefix increment).




let x = 10;
console.log(++x);
console.log(x);

Output: Here the value is first incremented and then returned.

11
11

Supported Browsers:

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

Article Tags :