Files
30-seconds-of-code/snippets/array-without.md
Angelos Chalaris 6bf0236731 Tag, lint, build
2017-12-15 12:53:09 +02:00

286 B

Array without

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

const without = (arr, ...args) => arr.filter(v => args.indexOf(v) === -1);
// 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 ]