Merge pull request #180 from iamsoorena/patch-1

updating array-without.md for more terse implementation and resolving…
This commit is contained in:
Angelos Chalaris
2017-12-16 13:37:20 +02:00
committed by GitHub

View File

@ -1,9 +1,9 @@
### Array without ### Array without
Use `Array.filter()` to create an array excluding all given values. Use `Array.filter()` to create an array excluding(using `!Array.includes()`) all given values.
```js ```js
const without = (arr, ...args) => arr.filter(v => args.indexOf(v) === -1); const without = (arr, ...args) => arr.filter(v => !args.includes(v));
// without[2, 1, 2, 3], 1, 2) -> [3] // 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 ] // without([2, 1, 2, 3, 4, 5, 5, 5, 3, 2, 7, 7], 3, 1, 5, 2) -> [ 4, 7, 7 ]
``` ```