Files
30-seconds-of-code/snippets/without.md
Angelos Chalaris 97c250bcfb Updated examples
2017-12-27 16:35:25 +02:00

384 B

without

Filters out the elements of an array, that have one of the specified values.

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

(For a snippet that mutates the original array see pull)

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