Guest User

Untitled

a guest
Apr 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. // difference
  2. let difference = arr1.filter(x => arr2.indexOf(x) == -1);
  3.  
  4.  
  5. // symmetric difference
  6. let difference = arr1
  7. .filter(x => arr2.indexOf(x) == -1)
  8. .concat(arr2.filter(x => arr1.indexOf(x) == -1));
  9.  
  10. // intersection
  11. let intersect = arr1.filter(n => arr2.indexOf(n) > -1);
Add Comment
Please, Sign In to add comment