Answers for "remove an element from array javascript by value"

282

Javascript remove array item by value

var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get  "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
Posted by: Guest on July-19-2019
10

js remove from array by value

const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Posted by: Guest on March-30-2020
3

delete from array based on value javascript

var index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Posted by: Guest on May-28-2020
2

js remove item from array by value

var arr = ['bill', 'is', 'not', 'lame'];

arr.splice(output_items.indexOf('not'), 1);

console.log(arr) //returns ['bill', 'is', 'lame']
Posted by: Guest on August-24-2020
1

remove a specific element from an array

array.splice(array.indexOf(item), 1);
Posted by: Guest on November-12-2020
3

how to remove a specific element from array in javascript

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
newArr.splice(1,2)
//remove 1 element from index 2
Posted by: Guest on August-22-2020

Code answers related to "remove an element from array javascript by value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language