Skip to content

Instantly share code, notes, and snippets.

@benjamingr
Created July 2, 2013 14:46
Show Gist options
  • Save benjamingr/5909909 to your computer and use it in GitHub Desktop.
Save benjamingr/5909909 to your computer and use it in GitHub Desktop.
Here is a solution using ES6 sets.
var a = new Set(Array1);
Array2.forEach(function(elem){
a.delete(elem);
});
return a;
@benjamingr
Copy link
Author

That assumes that adding properties and removing properties from a JS object is O(1), but it works :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment