Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array.prototype.subtract = function(...operands) {
- const ops = new Set(Array.prototype.concat(...operands));
- return this.filter(v => !ops.has(v));
- };
- ['a', 'c', 'b'].subtract(['d', 'c', 'y']); // ["a", "b"]
- ['a', 'c', 'b'].subtract(['d', 'c', 'y'], ['b', 'c']); // ["a"]
Add Comment
Please, Sign In to add comment