remove item from array
Just a simple function to remove an item from an Array. Works well in both, the browser & node.
install
npm i -S array-remove-item
and use it
import removeItemFromArray from 'array-remove-item'
// OR
const removeItemFromArray = require('array-remove-item')
const abcde = removeItemFromArray(['a', 'b', 'b', 'c', 'd', 'e'], 1)
console.log(abcde) // ['a', 'b', 'c', 'd', 'e']
behavior
-
removeItemFromArray
is a pure function, it does not mutate the provided array. - returns the same array if
- the position provided is not a number.
- no position is provided
- the position is out of the range of the array (grater than
arr.length
or less than 0)
FAQ
- Why such small module?: Sindre gives a good answer to this.