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'
const removeItemFromArray = require('array-remove-item')
const abcde = removeItemFromArray(['a', 'b', 'b', 'c', 'd', 'e'], 1)
console.log(abcde)
NOTE: it requires the rest operator to work. If you are not transpiling your code with Babel's es2015 preset (to work on the browser) or are using a node version older than 5, you will have to use the compiled version: require(array-remove-item/dist/array-remove-item.js).
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