In JavaScript, assignment operators are used to assign values to variables. They combine the assignment operation with one of the arithmetic or bitwise operators. Here are the most common assignment operators in JavaScript:
1) = (Assignment Operator): Assigns a value to a variable. For example:
2) += (Addition Assignment Operator): Adds a value to a variable and assigns the result to the same variable. For example:
3) -= (Subtraction Assignment Operator): Subtracts a value from a variable and assigns the result to the same variable. For example:
4) *= (Multiplication Assignment Operator): Multiplies a variable by a value and assigns the result to the same variable. For example:
5) /= (Division Assignment Operator): Divides a variable by a value and assigns the result to the same variable. For example:
6) %= (Modulo Assignment Operator): Computes the remainder of dividing a variable by a value and assigns the result to the same variable. For example:
7) <<= (Left Shift Assignment Operator): Shifts the bits of a variable to the left by a specified number of positions and assigns the result to the same variable. For example:
8) >>= (Right Shift Assignment Operator): Shifts the bits of a variable to the right by a specified number of positions and assigns the result to the same variable. For example:
9) &= (Bitwise AND Assignment Operator): Performs a bitwise AND operation on a variable and a value and assigns the result to the same variable. For example:
10) ^= (Bitwise XOR Assignment Operator): Performs a bitwise XOR operation on a variable and a value and assigns the result to the same variable. For example:
11) |= (Bitwise OR Assignment Operator): Performs a bitwise OR operation on a variable and a value and assigns the result to the same variable. For example:
Note that these assignment operators can be combined with each other.
That's it for JavaScript Assignment Operator. Thanks for reading and learning ❤️
#LetsCodeIt