Answers for "remove element with value from array 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
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
6

remove item from array by id

var myArr = [{id:'a'},{id:'myid'},{id:'c'}];
var index = arr.findIndex(function(o){
     return o.id === 'myid';
})
if (index !== -1) myArr.splice(index, 1);
Posted by: Guest on May-04-2020
0

remove value from array javascript

// remove 5
let arr = [1,2,3,4,5,6];
let remove = arr.filter((id) => id !== 5)
console.log(remove) // [1,2,3,4,6]
Posted by: Guest on May-15-2021
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

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language