Favorites

JavaScript -- Decrement Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
--
JavaScript Arithmetic OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The decrement operator (--) subtracts one from a variable. Like ++, it returns the old value in postfix form and the new value in prefix form.

Description

The decrement operator -- subtracts 1 from its operand and stores the result. x-- returns the original value, and --x returns the new value.

Like increment, the postfix and prefix forms only differ in the value the expression returns, not in their effect on the variable. while (count--) is a compact countdown loop: it tests the old value, so it runs once for each number down to 1 and stops when the value it checks is 0. A non-numeric value is converted to a number first, and undefined-- gives NaN.

The operand must be assignable, so --5 or (a + b)-- are syntax errors. Writing x -= 1 instead says the same thing more explicitly, and some style guides, and linter rules like ESLint's no-plusplus, prefer it for that reason.

Properties

Operator
--
Category
Arithmetic
Precedence
15 (1 is lowest, 18 is highest)
Associativity
n/a

Syntax

x--
--x

Example

let n = 3;
console.log(n--, n);
console.log(--n, n);
let count = 3;
while (count--) console.log('tick', count);

Browser Support

The following information will show you the current browser support for the -- operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee