Files
30-seconds-of-code/snippets/array-without.md
Soorena ee73677158 updating array-without.md for more terse implementation and resolving a bug in the comment
a bug in comments(forgotten parentheses) resolved.
and `Array.indexOf() === -1 ` changed to `Array.includes()`
2017-12-16 13:30:55 +03:30

10 lines
309 B
Markdown

### Array without
Use `Array.filter()` to create an array excluding(using `!Array.includes()`) all given values.
```js
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
// 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 ]
```