Guest User

Untitled

a guest
Oct 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. Array.prototype.subtract = function(...operands) {
  2. const ops = new Set(Array.prototype.concat(...operands));
  3. return this.filter(v => !ops.has(v));
  4. };
  5. ['a', 'c', 'b'].subtract(['d', 'c', 'y']); // ["a", "b"]
  6. ['a', 'c', 'b'].subtract(['d', 'c', 'y'], ['b', 'c']); // ["a"]
Add Comment
Please, Sign In to add comment