Array.prototype.unique = function() {
var arr = [];
var obj = {};
for(var i = 0; i < this.length; i++){
if(!obj[this[i]]){
arr.push(this[i]);
obj[this[i]] = 1;
}
}
return arr;
}
var arr = [1,1,2,2,3,3];
alert(arr.unique()) //[1, 2, 3]
1. 建立新数组存放独立内容
2. obj存放数组内容, 并且用来比较
...待完善