数组去重

57
function distinct(a, b) {
    return Array.from(new Set([...a, ...b]))
}

16
function distinct(a, b) {
    let arr = a.concat(b)
    let result = []
    let obj = {}

    for (let i of arr) {
        if (!obj[i]) {
            result.push(i)
            obj[i] = 1
        }
    }

    return result
}
原文地址:https://www.cnblogs.com/18553325o9o/p/9685090.html