You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
leta=50,b=100;console.log(a+b);// 150console.log(b-a);// 50console.log(a*b);// 5000console.log(b/a);// 2console.log(b%a);// 0// Increment & Decrementconsole.log(++a);// Pre-increment: 51console.log(a);// Value after increment: 51console.log(a++);// Post-increment: 51 (then a becomes 52)console.log(a);// Value after increment: 52console.log(--b);// Pre-decrement: 99console.log(b);// Value after decrement: 99console.log(b--);// Post-decrement: 99 (then b becomes 98)console.log(b);// Value after decrement: 98
2. Assignment Operators
Operator
Example
Equivalent To
=
x = y
Assign y to x
+=
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
Example:
letx=10;x+=5;// x = 15x-=2;// x = 13x*=2;// x = 26x/=2;// x = 13x%=3;// x = 1console.log(x);// 1