--- title: Subtraction assignment (-=) slug: Web/JavaScript/Reference/Operators/Subtraction_assignment translation_of: Web/JavaScript/Reference/Operators/Subtraction_assignment ---
The subtraction assignment operator (-=
) subtracts the value of the right operand from a variable and assigns the result to the variable.
Operator: x -= y Meaning: x = x - y
// Assuming the following variable // bar = 5 bar -= 2 // 3 bar -= 'foo' // NaN
Specification |
---|
{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}} |
{{Compat("javascript.operators.subtraction_assignment")}}