Javascript Array swap(indexA, indexB) method

Description

Javascript Array swap(indexA, indexB) method

Array.prototype.swap = function(indexA, indexB) {
 var temp;/*  ww w .  j  a v a 2 s  . co m*/
 temp = this[indexA];
 this.replace(indexA, 1, this[indexB]);
 this.replace(indexB, 1, temp);
 return this;
};



PreviousNext

Related