GitHub 6219★

Get union of arrays

JavaScript version

const union = (...arr) => [...new Set(arr.flat())];

TypeScript version

const union = <T,_>(...arr: T[][]): T[] => [...new Set(arr.flat())];

Example

union([1, 2], [2, 3], [3]); // [1, 2, 3]
Follow me on and to get more useful contents.