标签:
Array.prototype.prevRepeat = function(){
var newArr = new Array();
var Obj = new Object();
for(var i = 0;i<this.length;i++){
if(!Obj[this[i]]){
Obj[this[i]] = 1;
newArr.push(this[i]);
}
}
return newArr;
}
var arr = [1,2,1,1,5]
console.log(arr.prevRepeat())
标签:
原文地址:http://www.cnblogs.com/lzxb/p/5930313.html