Merge pull request #238 from leggsimon/patch-1

Add references to #pull/#without
This commit is contained in:
Angelos Chalaris
2017-12-19 12:30:42 +02:00
committed by GitHub
2 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,8 @@ Mutates the original array to filter out the values specified.
Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed.
Use `Array.length = 0` to mutate the passed in array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
_(For a snippet that does not mutate the original array see [`without`](#without))_
```js
const pull = (arr, ...args) => {
let pulled = arr.filter((v, i) => !args.includes(v));

View File

@ -4,6 +4,8 @@ Filters out the elements of an array, that have one of the specified values.
Use `Array.filter()` to create an array excluding(using `!Array.includes()`) all given values.
_(For a snippet that mutates the original array see [`pull`](#pull))_
```js
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
// without([2, 1, 2, 3], 1, 2) -> [3]