- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
- Binance Hack: $6.3 Billion Drained in the Largest Crypto Theft Ever. What We Know So Far
- This Site Uses XSLT Chrome Warning Explained: How to Fix It
- iPad mini OLED Price in India: Wi-Fi & Cellular Variants, Offers
Assignment operators are used to assign values to variables. JavaScript supports several assignment operators, including:
=(Assignment)+=(Addition assignment)-=(Subtraction assignment)*=(Multiplication assignment)/=(Division assignment)%=(Remainder assignment)
How to Use Assignment Operators
Here’s a brief explanation of how each operator works:
Assignment (=)
The = operator assigns the value on the right to the variable on the left.
let x = 5; // x is now 5
Addition Assignment (+=)
The += operator adds the value on the right to the variable on the left and assigns the result to the variable on the left.
let x = 5;
x += 3; // x is now 8
Subtraction Assignment (-=)
The -= operator subtracts the value on the right from the variable on the left and assigns the result to the variable on the left.
let x = 5;
x -= 3; // x is now 2
Multiplication Assignment (*=)
The *= operator multiplies the variable on the left by the value on the right and assigns the result to the variable on the left.
let x = 5;
x *= 3; // x is now 15
Division Assignment (/=)
The /= operator divides the variable on the left by the value on the right and assigns the result to the variable on the left.
let x = 6;
x /= 3; // x is now 2
Remainder Assignment (%=)
The %= operator divides the variable on the left by the value on the right and assigns the remainder to the variable on the left.
let x = 7;
x %= 3; // x is now 1
Understanding and using JavaScript’s assignment operators is fundamental to assigning and manipulating values in your code. They are essential tools in every developer’s toolkit.



