<script type="text/javascript" charset="utf-8" async defer>
var arr = [2,1,2,10,2,3,4,1,85,321,3,4,65,10,24];
function uniq(newarr){
function toObject(arr) {
var obj = { };
for(var i=0 ;i<arr.length ;i++){
obj[ arr[ i ] ]=true;
}
return obj ;
}
function keys(obj){
var arr = [ ] ;
for(var attr in obj){
if(obj.hasOwnProperty(attr)){
arr.push(parseInt(attr));
}
}
return arr;
}
return keys(toObject(newarr));
}
console.log(uniq(arr));
李晓健
相关分类