Decrement (--)

The decrement operator (--) decrements (subtracts one from) its operand and returns a value.


Operator: x-- or --x


If used postfix, with operator after operand (for example, x--), the decrement operator decrements and returns the value before decrementing.

If used prefix, with operator before operand (for example, --x), the decrement operator decrements and returns the value after decrementing.


Postfix decrement

let x = 3;
y = x--;

// y = 3
// x = 2

Prefix decrement

let a = 2;
b = --a;

// a = 1
// b = 1


ECMAScript (ECMA-262)
The definition of 'Decrement operator' in that specification.

Browser compatibility

ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Decrement (--)Chrome Full support 2Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 3.2Samsung Internet Android Full support 1.0nodejs Full support 0.1.100


Full support
Full support

See also