Increment (++)

The increment operator (++) increments (adds one to) its operand and returns a value.

Syntax

Operator: x++ or ++x

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.

Examples

Postfix increment

let x = 3;
y = x++;

// y = 3
// x = 4

Prefix increment

let a = 2;
b = ++a;

// a = 3
// b = 3

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Increment (++)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

Legend

Full support  
Full support

See also