--- title: 剰余代入 (%=) slug: Web/JavaScript/Reference/Operators/Remainder_assignment tags: - Assignment operator - JavaScript - Language feature - Operator - Reference translation_of: Web/JavaScript/Reference/Operators/Remainder_assignment ---
剰余代入演算子 (%=
) は、変数を右辺のオペランドの値で除算し、剰余を変数に代入します。
Operator: x %= y Meaning: x = x % y
// 以下の変数を想定 // bar = 5 bar %= 2 // 1 bar %= 'foo' // NaN bar %= 0 // NaN
仕様 |
---|
{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}} |
{{Compat("javascript.operators.remainder_assignment")}}