话不多说直接贴代码
Array.prototype.unique = function () {
return new Set(this)
}
console.log([1, 1, 2, 3, 4, {}, {}, []].unique());
//[1, 2, 3, 4, {}, {}, []]
话不多说直接贴代码
Array.prototype.unique = function () {
return new Set(this)
}
console.log([1, 1, 2, 3, 4, {}, {}, []].unique());
//[1, 2, 3, 4, {}, {}, []]