var arr=[1,1,1,1,2,2,2,3,3,4,1,4,5,7,8,7,7]
let m = {}
arr.filter(item => m[item] >= 1 ? false : (m[item] = (m[item] || 0) + 1))
//filter返回false删除掉遍历的当前元素,true留下当前元素
//(m[item] = (m[item] || 0) + 1) m[item]记录的是当前元素item出现的次数,可以打印出m看下效果
var arr=[1,1,1,1,2,2,2,3,3,4,1,4,5,7,8,7,7]
let m = {}
arr.filter(item => m[item] >= 2 ? false : (m[item] = (m[item] || 0) + 1))
[1, 2, 3, 4, 5, 7, 8]
[1, 1, 2, 2, 3, 3, 4, 4, 5, 7, 8, 7]