求两个数组的交集
var arr1 = [1,2,3]; var arr2 = [2,3,4]; var arr3; arr3 = arr1.filter(function(num) { return arr2.indexOf(num) !== -1; }); console.log(arr3); //输出[2, 3]
求两个数组的交集
var arr1 = [1,2,3]; var arr2 = [2,3,4]; var arr3; arr3 = arr1.filter(function(num) { return arr2.indexOf(num) !== -1; }); console.log(arr3); //输出[2, 3]