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…)