2024年08月02日 建站教程
let treeOneChecked2 = []//把自己的数组放进去 //找出相同数组 function duplicates(treeOneChecked2) { var newArr=[]; treeOneChecked2.sort(); for(var i =0;i<treeOneChecked2.length;i++){ if(treeOneChecked2[i]==treeOneChecked2[i+1]&&(newArr.indexOf(treeOneChecked2[i])==-1) ){ newArr.push(treeOneChecked2[i]); i++; } } return newArr; } var treeOne = duplicates(treeOneChecked2).sort() console.log('treeOne',treeOne); //找出不同数组 function getArrDifference(treeCheckedAll, treeOne) { return treeCheckedAll.concat(treeOne).filter(function(v, i, arr) { return arr.indexOf(v) === arr.lastIndexOf(v); }); } var treeTwo = getArrDifference(treeCheckedAll,treeOne) console.log('treeTwo', treeTwo);
本文链接:http://so.lmcjl.com/news/9796/