我在javascript中有两个数组,我想从中删除重复项
var array1 = [1,2,3,4,5,6,7,8,9];
var array2 = [3,5,7,11,17,19];
我希望输出为[1,2,3,4,5,6,7,8,9,11,17,19]
答案 0 :(得分:1)
var array1 = [1,2,3,4,5,6,7,8,9], array2 = [3,5,7,11,17,19];
var output = array1.concat(array2);
var output = output.filter(function (item, pos) {return output.indexOf(item) == pos});