The Wayback Machine - http://web.archive.org/web/20230308024546/https://www.geeksforgeeks.org/javascript-arithrmetic-increment-operator/
Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Arithrmetic Increment(+ +) Operator

Improve Article
Save Article
  • Last Updated : 06 Mar, 2023
Improve Article
Save Article

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).

Javascript




var 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).

Javascript




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

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

11
11

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!