数组去重

// 数组去重合并
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

posted @ 2020-05-02 16:09  只争朝夕,不负韶华  阅读(142)  评论(0)    收藏  举报