Subtraction Assignment Operator(-=)

The Substraction Assignment Operator subtracts the value of the right operand from a variable and assigns the result to the variable.

Example:

Javascript
let yoo = 4;

// Expected output 3
console.log(foo = yoo - 1); 

Output:

3

JavaScript Assignment Operators

Similar Reads

Assignment Operators

Assignment operators are used to assign values to variables in JavaScript....

Assignment Operators List

There are so many assignment operators as shown in the table with the description....

Addition Assignment Operator(+=)

The Addition assignment operator adds the value to the right operand to a variable and assigns the result to the variable. Addition or concatenation is possible. In case of concatenation then we use the string as an operand....

Subtraction Assignment Operator(-=)

The Substraction Assignment Operator subtracts the value of the right operand from a variable and assigns the result to the variable....

Multiplication Assignment Operator(*=)

The Multiplication Assignment operator multiplies a variable by the value of the right operand and assigns the result to the variable....

Division Assignment Operator(/=)

The Division Assignment operator divides a variable by the value of the right operand and assigns the result to the variable....

Remainder Assignment Operator(%=)

The Remainder Assignment Operator divides a variable by the value of the right operand and assigns the remainder to the variable....

Exponentiation Assignment Operator

The Exponentiation Assignment Operator raises the value of a variable to the power of the right operand....

Left Shift Assignment Operator(<<=)

This Left Shift Assignment Operator moves the specified amount of bits to the left and assigns the result to the variable....

Right Shift Assignment Operator(>>=)

The Right Shift Assignment Operator moves the specified amount of bits to the right and assigns the result to the variable....

Bitwise AND Assignment Operator(&=)

The Bitwise AND Assignment Operator uses the binary representation of both operands, does a bitwise AND operation on them, and assigns the result to the variable....

Btwise OR Assignment Operator(|=)

The Btwise OR Assignment Operator uses the binary representation of both operands, does a bitwise OR operation on them, and assigns the result to the variable....

Bitwise XOR Assignment Operator(^=)

The Bitwise XOR Assignment Operator uses the binary representation of both operands, does a bitwise XOR operation on them, and assigns the result to the variable....

Logical AND Assignment Operator(&&=)

The Logical AND Assignment assigns the value of y into x only if x is a truthy value....

Logical OR Assignment Operator(||=)

The Logical OR Assignment Operator is used to assign the value of y to x if the value of x is falsy....

Nullish coalescing Assignment Operator(??=)

The Nullish coalescing Assignment Operator assigns the value of y to x if the value of x is null....