2. JavaScript Assignment
Operator Example Same As
= x = y x = y
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= y x = x % y
<<= x <<= y x = x << y
>>= x >>= y x = x >> y
>>>= x >>>= y x = x >>> y
&= x &= y x = x & y
^= x ^= y x = x ^ y
|= x |= y x = x | y
**= x **= y x = x ** y
Youtube @Learn With Vivek | learnwithvivek.in
5. Assignment
Examples
Youtube @Learn With Vivek | learnwithvivek.in
The -= assignment operator
subtracts a value from a
variable.
Assignment
let x = 10;
x -= 5;
8. Assignment
Examples
Youtube @Learn With Vivek | learnwithvivek.in
The %= assignment operator
assigns a remainder to a variable.
Assignment
let x = 10;
x %= 5;
9. Assignment
Examples
Youtube @Learn With Vivek | learnwithvivek.in
The %= assignment operator
assigns a remainder to a
variable.
Assignment
let x = 10;
x %= 5;
10. Assignment Examples
• Use the correct assignment operator that will result in x being 15
• x = 10;
• y = 5;
• x __ y;
Youtube @Learn With Vivek | learnwithvivek.in