ES6 - Assignment Operators Example


Advertisements

The following program is a simple example that demonstrates the assignment operators.

Example

var a = 12; 
var b = 10; 
a = b;
console.log("a = b: " + a); 
a += b; 

console.log("a+=b: " + a); 
a -= b; 

console.log("a-=b: " + a); 
a *= b; 

console.log("a*=b: " + a); 
a /= b; 

console.log("a/=b: " + a); 
a %= b; 

console.log("a%=b: " + a);

The following output is displayed on successful execution of the above program.

a=b: 10 
a+=b: 20 
a-=b: 10 
a*=b: 100 
a/=b: 10 
a%=b: 0
es6_operators.htm
Advertisements