/p>
"http://www.w3.org/TR/html4/loose.dtd">
var arr = [1,2,3,2,3,4,5,6,7,8,9,8,5];
//将数组转换成对象
//利用对象的key值不能重复这一特性
var toObject = function(array) {
var obj = {};
for(var i=0,j=array.length;i
obj[array[i]] = true;
}
return obj;
}
//再将对象转换成数组
var toArray = function(obj){
var arr = [];
for(var i in obj){
arr.push(i);
}
return arr;
}
//综合前两者,完成去数组重复项方法
var uiq = function(arr){
return toArray(toObject(arr));
}
var arr1 = uiq(arr);
console.log(arr1);