, the simplest way I can think of to switch the values
b is this:
Right? Of course it is slower than using just a temporary variable (see http://jsperf.com/variable-switch), which is also something one should know about.
In ES6 this can be done simply by something called destructuring assignment, which for arrays looks like this: