复杂数组去重
let arr = [3, 1, [1], 1, [1], true, true, {}, '1', NaN, undefined, NaN, undefined, {}, null, null] const set = new Set() const result = [...new Set(arr)].filter(item=>{ if(typeof item !== 'object' || item === null){ return true }else if(set.has(JSON.stringify(item))){ return false }else{ set.add(JSON.stringify(item)) return true } }) console.log(result)