JavaScript Assignment Operators
The assignment operation evaluates the assigned value. Chaining the assignment operator is possible in order to assign a single value to multiple variables
Name |
Description |
Syntax |
Example |
Assignment (=) |
This operator assigns the right operand value to the left operand. |
If A = 10 and Y = A then Y = 10 |
|
Sums up left and right operand values and then assigns the result to the left operand. |
Y += 1 gives Y = Y + 1 |
||
It subtracts the right side value from the left side value and then assigns the result to the left operand. |
Y -= 1 gives Y = Y – 1 |
||
It multiplies a variable by the value of the right operand and assigns the result to the variable. |
Y *= A is equivalent to Y = Y * A |
||
It divides a variable by the value of the right operand and assigns the result to the variable. |
Y /= A is equivalent to Y = Y / A |
||
It divides a variable by the value of the right operand and assigns the remainder to the variable. |
Y %= A is equivalent to Y = Y % A |
||
This raises the value of a variable to the power of the right operand. |
Y **= A is equivalent to Y=Y ** A |
||
It moves the specified amount of bits to the left and assigns the result to the variable. |
Y <<= A is equivalent to Y=Y << A |
||
It moves the specified amount of bits to the right and assigns the result to the variable. |
Y >>= A is equivalent to Y = Y >> A |
||
: It does a bitwise AND operation on the operand, and assigns the result to the variable. |
Y &= b is equivalent to Y = Y & A |
||
It does a bitwise OR operation on the operand, and assigns the result to the variable. |
Y |= A is equivalent to Y= Y | b |
||
It does a bitwise XOR operation on the operand, and assigns the result to the variable. |
Y ^= A is equivalent to Y= Y ^ A |
JavaScript Operators
JavaScript operators are symbols used to perform specific mathematical, comparison, assignment, and logical computations on operands. They are fundamental elements in JavaScript programming, allowing developers to manipulate data and control program flow efficiently. Understanding the different types of operators and how they work is important for writing effective and optimized JavaScript code.
JavaScript Operators: There are various operators supported by JavaScript.
Table of Content
- JavaScript Arithmetic Operators
- JavaScript Assignment Operators
- JavaScript Comparison Operators
- JavaScript Logical Operators
- JavaScript Bitwise Operators
- JavaScript Ternary Operators
- JavaScript Comma Operators
- JavaScript Unary Operators
- JavaScript Relational Operators
- JavaScript BigInt Operators
- JavaScript String Operators