Quantcast
Viewing all articles
Browse latest Browse all 31

Add a Number to Two Variables At Once

You can initialize two variables to the same value at once, kinda:

var foo, bar;
foo = bar = 10;

But there is no similarly easy mechanism to add, say, 5 to both foo and bar at the same time. Of course, it's simple enough to just do:

foo += 5; // foo is now 15
bar += 5; // bar is now 15

But that's two operations. (more…)


Viewing all articles
Browse latest Browse all 31

Trending Articles