Skip to content

Instantly share code, notes, and snippets.

@Abrifq
Last active September 4, 2019 12:32
Show Gist options
  • Save Abrifq/7c5002128f0047f667b4e150f04b06c6 to your computer and use it in GitHub Desktop.
Save Abrifq/7c5002128f0047f667b4e150f04b06c6 to your computer and use it in GitHub Desktop.
This function takes an array as an input, then produces a NOT match filter Function, which can be used with Array.prototype.filter later on.
const notMatch = array => value => !array.includes(value);
//testing
const newFilter = notMatch([3,5]);
const array125 = [... Array(125).keys()];
console.log ( array125.length);
const filteredArray = array125.filter(newFilter);
console.log ( filteredArray.length)
//Lets try to get the [3,5] array back using two NOT filters
console.log ( array125.filter ( notMatch(filteredArray)) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment