Files
30-seconds-of-code/snippets/without.md
Isabelle Viktoria Maciohsek aa425812b4 Update snippet descriptions
2020-10-22 20:24:44 +03:00

18 lines
380 B
Markdown

---
title: without
tags: array,beginner
---
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.
```js
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
```
```js
without([2, 1, 2, 3], 1, 2); // [3]
```