1.数组去重
function unique(arr){
return arr.filter(function(item,index){
return arr.indexOf(item) == index;
})
}
2.深拷贝数组或者对象
function deepClone(a){
var newObj = Object.prototype.toString.call(a) === "[object Array]"?[]:{};
for (var i in a){
if (a.hasOwnPropertyof(i)){
newObj[i] = typeof a[i] =="object"?deepClone(a[i]):a[i];
}
}
return a;
}