可以使用Set集合的不可重复性来处理js的数组去重:
const arr = [1, 2,null,'hellow', 'hellow', 2, null] let set = new Set(arr); console.log(Array.from(set)) // [1,2,null,'hellow'] console.log([...set]) // [1,2,null,'hellow']
可以使用Set集合的不可重复性来处理js的数组去重:
const arr = [1, 2,null,'hellow', 'hellow', 2, null] let set = new Set(arr); console.log(Array.from(set)) // [1,2,null,'hellow'] console.log([...set]) // [1,2,null,'hellow']
转载于:https://www.cnblogs.com/yaoya/p/9959162.html