http://underscorejs.org/#difference
difference_.difference(array, *others)
Similar to without, but returns the values from array that are not present in the other arrays.
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
=> [1, 3, 4]
if ( _.difference(arr1, arr2).length == 0 && _.difference(arr2, arr1).length == 0 ) {
//两个数组相同, 数组元素有obj之类的不知行不行
}
可以使用
es7数组新增的includes方法。遍历数组a, 然后看数组b是否includes。数组实例的includes
改进算法
缺陷:比较数组的时候必须按顺序相等,因为数级里的 object 没法排序
连接两个数组,用hash判断重复
https://github.com/hanzichi/u... 不知道有没有帮助