Merge pull request #213 from schichulin/master

Fix Array pull (mutates array) to pull out values correctly
This commit is contained in:
Angelos Chalaris
2017-12-17 15:23:28 +02:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@ -163,7 +163,7 @@ Use `Array.length = 0` to mutate the passed in array by resetting it's length to
```js
const pull = (arr, ...args) => {
let pulled = arr.filter((v, i) => args.includes(v));
let pulled = arr.filter((v, i) => !args.includes(v));
arr.length = 0; pulled.forEach(v => arr.push(v));
};
// let myArray = ['a', 'b', 'c', 'a', 'b', 'c'];

View File

@ -5,7 +5,7 @@ Use `Array.length = 0` to mutate the passed in array by resetting it's length to
```js
const pull = (arr, ...args) => {
let pulled = arr.filter((v, i) => args.includes(v));
let pulled = arr.filter((v, i) => !args.includes(v));
arr.length = 0; pulled.forEach(v => arr.push(v));
};
// let myArray = ['a', 'b', 'c', 'a', 'b', 'c'];