Tag:font Otherwise start cti save style traversal representation mil
Array.prototype.unique1 = function () {var n = [];//A new temporary array for (var i = 0; i < this.length; i++)//traverse the current array {//If the current array is already insured Save in a temporary array, skip,//Otherwise push the current item into the temporary array if (N.indexof (this[i]) = = 1) n.push (This[i]);} return n;}
Array.prototype.unique2 = function () {var n = {},r=[];//n is a hash table, r is a temporary array for (var i = 0; i < this.length; i++)//traverse the current array {if (!n[this[i])//If the hash table does not have the current item {N[this[i]] = true;//hash Table R.push (this[i]);//Push the current item of the current array into the temporary array}}return R;
Array.prototype.unique3 = function () {var n = [this[0]];//result array for (var i = 1; i < this.length; i++)//start with the second entry {//if the current array The first occurrence of item I in the current array is not i,//so it means that item I is duplicated and ignored. Otherwise deposit the result array if (This.indexof (this[i]) = = i) N.push (This[i]);} return n;}
About JS array de-weight