记录两种 Set 类去重办法
-
数组去重 […new Set(array)]
let arr = [1,1,1,1,1,1,2,2,2,2,3,3,3,5,5,6,6,7,8] console.log([...new Set(arr)])
-
字符串去重 […new Set(‘ababbc’)].join(”)
let str = 'asdsdaasqwqeqwessdddfffsadasd' console.log([...new Set(str)].join('')
记录两种 Set 类去重办法
数组去重 […new Set(array)]
let arr = [1,1,1,1,1,1,2,2,2,2,3,3,3,5,5,6,6,7,8]
console.log([...new Set(arr)])
字符串去重 […new Set(‘ababbc’)].join(”)
let str = 'asdsdaasqwqeqwessdddfffsadasd'
console.log([...new Set(str)].join('')