Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function arrayDiff( a1, a2) {
- var common = []
- var a1only = []
- var a2only = [].concat(a2)
- a1.forEach( e=>{
- if (a2only.includes(e)) {
- common.push(e)
- a2only.splice( a2only.indexOf(e), 1)
- } else {
- a1only.push(e)
- }
- })
- return { common, a1only, a2only}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement