数组去重
ts
uniq([2, 1, 2]) // => [2, 1]
要处理的数组
返回新数组
数组去重,每一个数组的元素调用 iteratee 产生唯一性计算标准
uniqBy([2.1, 1.2, 2.3], Math.floor) // => [2.1, 1.2]
迭代函数
数组去重,数组每一个元素都接受一个 comparator 函数做对比
const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }] uniqWith(objects, isEqual) // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
对比函数,传入两个参数 (value , otherValue),return true为去重
Generated using TypeDoc
数组去重
ts
uniq([2, 1, 2]) // => [2, 1]