Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Teachable.

Increment and decrement operators – JavaScript

Length: 10 minutes

Summary

++
--

Details

The increment and decrement operators can be used to increase or decrease the number stored inside a variable.

Increment operator

The increment operator takes the value inside the variable, adds 1 to it, and stores the new value inside the variable.

let a = 1;
a++;
// result: 2

Decrement operator

The decrement operator takes the value inside the variable, subtracts 1 from it, and stores the new value inside the variable.

let a = 1;
a--;
// result: 0

Demo

Exercises

Try the following statements in the console:

let a = 1
a++
a--

References

Expressions and operators on MDN

Back to: JavaScript Reference > JS Data Types