Merge pull request #283 from kingdavidmartins/fix-pull
[UPDATE] pull.md -> fix hacky approach
This commit is contained in:
@ -9,8 +9,10 @@ _(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.toString().split(',').includes(v));
|
||||
arr.length = 0; pulled.forEach(v => arr.push(v));
|
||||
let argState = Array.isArray(args[0]) ? args[0] : args;
|
||||
let pulled = arr.filter((v, i) => !argState.includes(v));
|
||||
arr.length = 0;
|
||||
pulled.forEach(v => arr.push(v));
|
||||
};
|
||||
|
||||
// let myArray1 = ['a', 'b', 'c', 'a', 'b', 'c'];
|
||||
|
||||
Reference in New Issue
Block a user