boys-utils
v1.0.1
Published
常用的JavaScript工具函数,可以下载体验一下
Downloads
17
Maintainers
Readme
utils工具集工具介绍
ArrayUnion(array1, array2, key)
// 实例1:
let a = [1, 2, 3, 4, 5]
let b = [1, 2, 4, 5, 6]
ArrayUnion(a, b) // [1,2,3,4,5,6]
// 实例2:
let a1 = [
{ id: 1, name: '张三', age: 20 },
{ id: 2, name: '李四', age: 21 },
{ id: 3, name: '小二', age: 23 }
]
let b1 = [
{ id: 2, name: '李四', age: 21 },
{ id: 4, name: '小明', age: 24 },
{ id: 5, name: '小红', age: 25 }
]
// 通过 id 获取并集
ArrayUnion(a1, b1, 'id')
[
{id: 1, name: "张三", age: 20}
{id: 2, name: "李四", age: 21}
{id: 3, name: "小二", age: 23}
{id: 4, name: "小明", age: 24}
{id: 5, name: "小红", age: 25}
]