Javascript Array switch(a, b)
Array.prototype.switch = function (a, b) { var x = this[b]; this[b] = this[a];/*from w w w.j a v a 2 s . co m*/ this[a] = x; return this; };