Files
30-seconds-of-code/snippets/without.md
Stefan Feješ f559030eac fix naming
2017-12-17 15:41:31 +01:00

309 B

Array without

Use Array.filter() to create an array excluding(using !Array.includes()) all given values.

const without = (arr, ...args) => arr.filter(v => !args.includes(v));
// without([2, 1, 2, 3], 1, 2) -> [3]
// without([2, 1, 2, 3, 4, 5, 5, 5, 3, 2, 7, 7], 3, 1, 5, 2) -> [ 4, 7, 7 ]