You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
323 B
13 lines
323 B
|
3 years ago
|
/**
|
||
|
|
* @description: 数组并集
|
||
|
|
* @param {Array} arr1
|
||
|
|
* @param {Array} arr2
|
||
|
|
* @return {Array}
|
||
|
|
* @example: arrayUnion([1,2,3],[2,3,4]) //[1, 2, 3, 4]
|
||
|
|
*/
|
||
|
|
export default function arrayUnion(arr1 = [], arr2 = []) {
|
||
|
|
const set1 = new Set(arr1);
|
||
|
|
const set2 = new Set(arr2);
|
||
|
|
return [...new Set([...set1, ...set2])];
|
||
|
|
}
|