インクリメント (++)

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

インクリメント演算子 (++) は、オペランドをインクリメント (1 を加算) して値を返します。

試してみましょう

let x = 3;
const y = x++;

console.log(`x:${x}, y:${y}`);
// Expected output: "x:4, y:3"

let a = 3;
const b = ++a;

console.log(`a:${a}, b:${b}`);
// Expected output: "a:4, b:4"

構文

js
x++;
++x;

解説

オペランドに後置で演算子を付けると (例えば、 x++) 、インクリメント演算子はインクリメントしますが、インクリメント前の値を返します。

オペランドに前置で演算子を付けると (例えば、 ++x) 、インクリメント演算子はインクリメントし、インクリメント後の値を返します。

後置インクリメント

js
let x = 3;
y = x++;

// y = 3
// x = 4

前置インクリメント

js
let a = 2;
b = ++a;

// a = 3
// b = 3

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-postfix-increment-operator

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Increment (++)

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報