Pre-increment

The variable is incremented first, and then the updated value is used in the expression.

Example: Using pre-increment.

Javascript




let a = 10;
let b = ++a;
 
console.log(a); // Outputs 11 (original value incremented)
console.log(b); // Outputs 11 (updated value used in the expression)


Output

11
11

How to Increment a Variable by 1 in JavaScript ?

In JavaScript, you can increment a variable by 1 using the increment operator (++). There are two ways to use this operator:

Similar Reads

Post-increment

The current value of the variable is used in the expression, and then the variable is incremented....

Pre-increment

...