Skip to content

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

License

Notifications You must be signed in to change notification settings

javascriptutils/remove-item-from-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published