const getRes = (arr, obj = {}) => {
return arr.filter((item, index, arr) => {
let judgeRule
if (Object.prototype.toString.call(item) === "[object Object]") {
judgeRule = "object" + Object.entries(item)
} else judgeRule = typeof item + item
return obj.hasOwnProperty(judgeRule) ? false : (obj[judgeRule] = true)
})
}
console.log(
[
{ a: 1 },
{},
{ a: 1 },
{ a: 1, b: [] },
[1, 2],
[1, 2],
"123",
123,
null,
null,
NaN,
undefined,
],
getRes([
{ a: 1 },
{},
{ a: 1 },
{ a: 1, b: [] },
[1, 2],
[1, 2],
"123",
123,
null,
null,
NaN,
undefined,
])
)