1.判断是否为一个空对象
let a={};
console.log(Object.keys(arr).length==0);//true
2.从数组中取出重复的数据
var arr = ["1","2","3","2","1"];
var tmp=[];
arr.forEach(function (item) {
(arr.indexOf(item) !== arr.lastIndexOf(item) && tmp.indexOf(item) === -1) && tmp.push(item)
})
console.log(tmp);//["1","2"]