Path: blob/main/files/en-us/web/javascript/reference/operators/decrement/index.md
6517 views
------{{jsSidebar("Operators")}}
The decrement (--) operator decrements (subtracts one from) its operand and returns the value before or after the decrement, depending on where the operator is placed.
{{EmbedInteractiveExample("pages/js/expressions-decrement.html")}}
Syntax
Description
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.
The decrement operator can only be applied on operands that are references (variables and object properties; i.e. valid assignment targets). --x itself evaluates to a value, not a reference, so you cannot chain multiple decrement operators together.
Examples
Postfix decrement
Prefix decrement
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}