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