var arr1 = ['1', '2', '3', '4', '3']
var arr2 = ['1', '3']
var arr3 = arr1.filter(el => !arr2.includes(el))
console.log(arr3)
includes 是 es 6 的,也可以用下面的,箭头函数es6的,不行你就转成普通函数:
var arr3 = arr1.filter(el => !~arr2.indexOf(el))
Copyright © 2024 zkx4213
Powered by .NET 9.0 on Kubernetes