1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /*--------------------------------------------------------------------------*\ Function: Array.remove_duplicates Description: useful method for Array objects which removes all duplicate elements. \*--------------------------------------------------------------------------*/ Array.prototype.remove_duplicates = function() { var temp = new Array(); this.sort(); for (var i=0; i<this.length; i++) { if (this[i] == this[i+1]) continue; temp[temp.length] = this[i]; } return temp; } |
Recent Comments