JS-022
JavaScript diagram about Increment ++: a visual example of Increase a value by one
Beginner2 min~2 min read#increment#++#operators

Increment ++

Increase a value by one

Goal

Learn how to use the ++ operator to increase a variable's value.

Explanation

  • The ++ operator increases a variable's value by exactly one.
  • It is shorthand for x = x + 1.
  • Increment is very common in counters, loops, and games.
  • After the operator runs, the variable holds the new value.
  • It is one of the most widely used operators in JavaScript.

Analogy

Imagine a scoreboard. After each goal, someone presses a button and the number automatically goes up by one.

Code

let score = 5;

score++;

console.log(score);

Result: 6

Common mistake

You cannot write 5++. The ++ operator works only with a variable, not a plain number.

Remember

  • ++ adds one.
  • x++ means x = x + 1.
  • Increment works only with variables.

Quick Quiz

What value will score have after score++ if score starts at 5?

Resources