デクリメント (--)

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:2, y:3"

let a = 3;
const b = --a;

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

構文

js
x--;
--x;

解説

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

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

後置デクリメント

js
let x = 3;
y = x--;

// y = 3
// x = 2

前置デクリメント

js
let a = 2;
b = --a;

// a = 1
// b = 1

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-postfix-decrement-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
Decrement (--)

Legend

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

Full support
Full support

関連情報