Answers for "remove item from array with value javascript"

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
1

remove a value from array js

const index = array.indexOf(item);
if (index > -1) {
	array.splice(index, 1);
}
Posted by: Guest on December-04-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
0

remove item from array by value

var index = array.indexOf(item);
if (index !== -1) {
  array.splice(index, 1);
}
Posted by: Guest on April-18-2021

Code answers related to "remove item from array with value javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language