JavaScript Increment Operator


Arithmetic Increment

++ symbol is used for arithmetic increment operator

arithmetic increment operator takes a variable as operand, increments the value in the variable by one

based on whether the incremented value is reflected in the variable during post executing the statement, or while executing the statement, there are two types of increment operations: post-increment, and pre-increment.

a++  //post-increment
++a  //pre-increment 

Examples

1. increment a

var a = 6;
a++;
console.log(a);

2. post-increment a

var a = 6;
console.log(a++);
//6
console.log(a);
//7

3. pre-increment a

var a = 6;
console.log(++a);
//7
console.log(a);
//7