減算代入 (-=)

減算代入演算子 (-=) は、変数から右辺のオペランドの値を減算し、結果を変数に代入します。

試してみましょう

構文

x -= y // x = x - y

減算代入の使用

// 次の変数を想定
//  bar = 5

bar -= 2     // 3
bar -= 'foo' // NaN

仕様書

Specification
ECMAScript Language Specification
# sec-assignment-operators

ブラウザーの互換性

BCD tables only load in the browser

関連情報