Files
30-seconds-of-code/snippets/without.md
Isabelle Viktoria Maciohsek 8bf67754ce Make expertise a field
2022-03-01 20:21:45 +02:00

494 B

title, tags, expertise, firstSeen, lastUpdated
title tags expertise firstSeen lastUpdated
Filter out matching array elements array beginner 2017-12-15T09:35:30+02:00 2020-10-22T20:24:44+03:00

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

  • Use Array.prototype.includes() to find values to exclude.
  • Use Array.prototype.filter() to create an array excluding them.
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
without([2, 1, 2, 3], 1, 2); // [3]