Path: blob/main/files/en-us/web/javascript/reference/operators/increment/index.md
6520 views
------{{jsSidebar("Operators")}}
The increment (++) operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.
{{EmbedInteractiveExample("pages/js/expressions-increment.html")}}
Syntax
Description
If used postfix, with operator after operand (for example, x++), the increment operator increments and returns the value before incrementing.
If used prefix, with operator before operand (for example, ++x), the increment operator increments and returns the value after incrementing.
The increment 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 increment operators together.
Examples
Postfix increment
Prefix increment
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}