Merge pull request #238 from leggsimon/patch-1
Add references to #pull/#without
This commit is contained in:
@ -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));
|
||||
|
||||
@ -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]
|
||||
|
||||
Reference in New Issue
Block a user