Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. function arrayDiff( a1, a2) {
  2. var common = []
  3. var a1only = []
  4. var a2only = [].concat(a2)
  5.  
  6. a1.forEach( e=>{
  7. if (a2only.includes(e)) {
  8. common.push(e)
  9. a2only.splice( a2only.indexOf(e), 1)
  10. } else {
  11. a1only.push(e)
  12. }
  13. })
  14.  
  15. return { common, a1only, a2only}
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement