数组去重
// 数组去重合并
function hello(){
console.log("hello");
}
function combine(){
return Array.from(new Set([].concat(...arguments)))
}
console.log(combine([1,2,3],[2,3,4],hello,"你好",{hello:"你好"},"你好"));
// [1, 2, 3, 4, hello(), "你好", {hello:"你好"}]
展开运算符... 对 函数形参的类数组展开后使用concat合并,再通过new Set去重生成set,在 Array.from将set转换为array

浙公网安备 33010602011771号