在循环过程中如何跳过数据库中已有的重复数据? 如何剔除本次循环中的重复数据?
10 回复
underscore 里有 uniq 函数可以选出不重复的数组内容
uniq_.uniq(array, [isSorted], [iteratee]) Alias: unique
Produces a duplicate-free version of the array, using === to test object equality. If you know in advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If you want to compute unique items based on a transformation, pass an iteratee function.
_.uniq([1, 2, 1, 3, 1, 4]);
=> [1, 2, 3, 4]