CKTIS / JavaScript
Increment operator (++)
The ++ operator adds one to a numeric value and attempts to write the result back to its operand. The count++ form returns the previous numeric value, while ++count returns the new value.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
target++
++targetThe ++ operator reads its operand, converts its value using ToNumeric, adds one, and attempts to write the result back. For Number it adds 1; for BigInt it adds 1n.
The postfix form count++ returns the previous value after numeric conversion; the prefix form ++count returns the new value. Both perform the assignment before the expression finishes evaluating: postfix does not postpone the write. As standalone statements, they have the same side effects.
The assignment does not guarantee that the result is stored. A property setter can accept and discard the value, and a write to a non-writable property can be ignored in non-strict code. In either case, the expression can still return a numeric value.
The operand must be a valid assignment target. A variable declared with let or a writable object property can be used. 1++ is a syntax error, while incrementing a const variable throws TypeError. In postfix form, no line terminator may appear between the operand and ++.
Conversion matters: with let text = "7", the expression text++ returns the number 7 and stores the number 8, not a string. Therefore, do not assume ++ is interchangeable with += 1, which can concatenate strings. Number arithmetic is subject to rounding; NaN remains NaN.
Examples
let count = 3;
const before = count++;
const after = ++count;
console.log(before, after, count);
let text = "7";
const previous = text++;
console.log(previous, text, typeof text);Result
3 5 5 7 8 number
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.