Unique array with a custom equality function
通过自定义相等函数实现数组去重
The array to remove duplicates from / 要去重的数组
The function to determine equality between elements / 判断元素是否相等的函数
The array with duplicates removed / 去重后的数组
Time complexity: O(n²). For large arrays, consider using uniqBy with a key function for O(n) performance.
时间复杂度:O(n²)。对于大数组,建议使用 uniqBy 配合键函数以获得 O(n) 性能。
uniqWith([1, 1, 2, 2, 3, 3], (a, b) => a === b)// => [1, 2, 3] Copy
uniqWith([1, 1, 2, 2, 3, 3], (a, b) => a === b)// => [1, 2, 3]
Unique array with a custom equality function
通过自定义相等函数实现数组去重