JavaScript Mathematic operations and assignment


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;