Files
30-seconds-of-code/snippets/without.md
2020-09-15 21:52:00 +03:00

17 lines
358 B
Markdown

---
title: without
tags: array,beginner
---
Filters out the elements of an array, that have one of the specified values.
- Use `Array.prototype.filter()` to create an array excluding(using `!Array.includes()`) all given values.
```js
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
```
```js
without([2, 1, 2, 3], 1, 2); // [3]
```