remove-item-from-array

Removes items with a specified value from an array and returns the modified array.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
remove-item-from-array
1.0.42 years ago2 years agoMinified + gzip package size for remove-item-from-array in KB

Readme

Remove an Item From an Array
A utility to remove items that match a specified value from an array. Works recursively to remove items from nested arrays.

Install

npm i remove-item-from-array --save

Usage

removeArrayItem(arr, item)

The module exports a function; the first argument is the current array, the second is the value of items that should be removed.

Examples

import removeArrayItem from 'remove-item-from-array'

const arr = removeArrayItem(['cat', 'dog', ['cat', 'goose']], 'cat')

// arr will be ['dog', ['goose']]

You can also pass additional values as arguments to remove multiple items in one statement:
const arr = removeArrayItem(['cat', 'dog', ['goose']], 'cat', 'dog')

// arr will be [['goose']]

Links & Resources

Demo on Codesandbox.io
Examples on Codesandbox.io
remove-item-from-array on javascriptutils.com
remove-item-from-array on GitHub
remove-item-from-array on NPM
remove-item-from-array on Aliyun
remove-item-from-array on TAONPM
remove-item-from-array on jsDlivr
remove-item-from-array on Snyk
remove-item-from-array on Libraries.io
remove-item-from-array on RunKit
remove-item-from-array on npm trends
remove-item-from-array on Package Phobia
remove-item-from-array on Skypack
remove-item-from-array on CNPM
remove-item-from-array on Openbase
remove-item-from-array on githubmemory
remove-item-from-array on npm.io
remove-item-from-array on Pkg Stats