/** * Get the union of arrays with unique values by means of the Set type. * * @param {Array} * @return {Array} */ function union () { return [...new Set(Array.prototype.reduce.call(arguments, (memo, array) => { memo.push(...array) return memo }, []))] } console.log(union([1, 2, 3], [2, 3, 4])) // => [1, 2, 3, 4]