orderd-array-remove
v1.1.0
Published
Removed an element from array by keeping order of elements inside array
Downloads
3
Maintainers
Readme
orderd-array-remove
Removed an element from array by keeping order of elements inside array
Install
$ npm install --save orderd-array-remove
Example
var remove = require('orderd-array-remove');
console.log(remove([1, 2, 3, 4, 5], 5));
// -> [1, 2, 4, 5]
Explination
In case the element not found in the list then the function returns an original array
var remove = require('orderd-array-remove');
console.log(remove([1, 2, 3, 4, 5], 10));
// -> [1, 2, 3, 4, 5]
The order need to be maintained so the particular element is searched by indexOf and removed the element by splice
require('orderd-array-remove')(array, element)
Arguments:
array
: listelement
: the element that need to be removed
Returns: Returns the updated array after removal of the element
License
© 2016 Vikram Jadhav. MIT License