const arra = ['a', 'b', 'c', 'd', 'e']; const arrb = ['b', 'e']; console.log("some: " + arra.filter(v => !arrb.some((item) => item === v))); console.log("find: " + arra.filter(v => !arrb.find((item) => item === v))); console.log("findIndex: " + arra.filter(v => arrb.findIndex((item) => item === v) < 0)); console.log("includes: " + arra.filter(v => !arrb.includes(v))); console.log(arra);
封装方法
function arrayAminusB(arrA, arrB) { return arrA.filter(v => !arrB.includes(v)); }
标签:console,arrb,arra,JavaScript,差集,filter,item,数组,log From: https://www.cnblogs.com/Console-LIJIE/p/17358060.html