Monday, January 25, 2016

asterisk equals in JavaScript

var x = 13;
x *= 3;
alert(x);

 
 

The alert will have a 39 in it. Basically, we suggest this instruction: Assign to the left the left multiplied by the right. So we assign into the variable holding 13 the product of 13 and 3. There is also a minus equals and I bet you can guess what that does. If you need it spelled out to you this has a more idiotproof explanation.

No comments:

Post a Comment