Skip to content

Instantly share code, notes, and snippets.

@clarencetw
Created May 16, 2019 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarencetw/00559d4528c0cb427bcaba5930bc44d7 to your computer and use it in GitHub Desktop.
Save clarencetw/00559d4528c0cb427bcaba5930bc44d7 to your computer and use it in GitHub Desktop.
const a = ['a', 'b'];
const b = ['b', 'c'];
Array.prototype.diff = function(a) {
return this.filter(function(i) {return a.indexOf(i) < 0;});
};
console.log("A diff B: ", a.diff(b));
console.log("B diff A: ", b.diff(a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment