子集问题最后返回的结果是二维数组
- 🤔,
[] !== [];{}!=={};2===2,为什么捏?- [] 与 [] 存储的内存地址不同,所以 !==
- 那一维数组的去重方法在二维数组这里是不适用的
<script>
var duplicate = function (arr) {
// 法一:es6
let res = new Map();
arr.forEach((item) => {
item.sort((a, b) => a - b);
res.set(item.join(), item);
});
return Array.from(res.values());
// 法二:
// let res = {};
// arr.forEach((item) => {
// item.sort((a, b) => a - b);
// res[item] = item;
// });
// return Object.values(res);
};
const arr = [
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[2, 3, 4, 5],
[6, 6, 6, 6],
];
console.log(duplicate(arr));
</script>

console.log([[1],[2],[3]].includes([1])) // false
[] === [] // false
console.log([[1],[2],[3]].indexOf([1])) // -1
(...new Set([],[])) // [[],[]]
in运算符惊到了我了!!!
console.log([1] in [[1],[2],[3]]) // true
console.log([1,2] in [[1,2],[2]]) // false???,玩啥呢,整蒙了