JavaScript Declarations and Assignments Mathematic operations and assignment

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Increment by

var a = 9,  
b = 3;  
b += a;  

b will now be 12

This is functionally the same as

b = b + a; 

Decrement by

var a = 9,  
b = 3;  
b -= a;  

b will now be 6

This is functionally the same as

b = b - a;  

Multiply by

var a = 5,  
b = 3;  
b *= a;  

b will now be 15

This is functionally the same as

b = b * a;  

Divide by

var a = 3,  
b = 15;  
b /= a;  

b will now be 5

This is functionally the same as

b = b / a;  

7

Raised to the power of

var a = 3,  
b = 15;  
b **= a;  

b will now be 3375

This is functionally the same as

b = b ** a;  


Got any JavaScript Question?