Answers for "delete a value from javascript array"

282

javascript array remove element

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
0

array value remove

const fruits = ["Banana", "Orange", "Apple", "Kiwi"];
fruits.splice(
1
, 
2
);
Posted by: Guest on October-20-2021

Code answers related to "delete a value from javascript array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language