js移除B中包含A的元素

var a = [1, 3, 5, 7, 9], b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
b = b.filter(function(e) { return a.indexOf(e) < 0; });
// b现在是[2, 4, 6, 8, 10]

猜你喜欢

转载自blog.csdn.net/wasd986523/article/details/80997762