a = [1,2,3,4,5]
b = [3,4,5]
a只保留[1,2]
答:
a = [1, 2, 3, 4, 5];
b = [3, 4, 5];
a = a.filter(item => b.indexOf(item) == -1);
console.log(a); // [1, 2]
相关博文
js如何去掉两个数组重复的值?
记录-交流-Web开发知识分享
a = [1,2,3,4,5]
b = [3,4,5]
a只保留[1,2]
答:
a = [1, 2, 3, 4, 5];
b = [3, 4, 5];
a = a.filter(item => b.indexOf(item) == -1);
console.log(a); // [1, 2]