Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Increment and Decrement Operators | Performing Operations in JavaScript
Introduction to JavaScript

book
Increment and Decrement Operators

Increment and Decrement are operations used to increase or decrease a variable's value by 1.

Increment

The increment operation is performed using the ++ operator:

let a = 0;
a++;
console.log(a);
a++;
console.log(a);
a++;
console.log(a);
1234567
let a = 0; a++; console.log(a); a++; console.log(a); a++; console.log(a);
copy

Note

The expression a++ is equivalent to a = a + 1 or a += 1.

Decrement

The decrement operation is performed using the -- operator:

let a = 5;
a--;
console.log(a);
a--;
console.log(a);
a--;
console.log(a);
1234567
let a = 5; a--; console.log(a); a--; console.log(a); a--; console.log(a);
copy

Note

The expression a-- is equivalent to a = a - 1 or a -= 1.

Increment and decrement operations are frequently used in loops, which we will discuss in more detail later.

question mark

Choose the correct result:

let a = 27;
a--;
a--;
a++;
a += 5;

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 4
some-alt