Answers for "javascript array remove index"

36

javascript remove from array by index

//Remove specific value by index
array.splice(index, 1);
Posted by: Guest on May-06-2020
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
19

how to remove element from array in javascript

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 April-23-2020
2

javascript remove element from array

const cars = ['farrari', 'Ice Cream'/* It is not an car */, 'tata', 'BMW']

//to remove a specific element
cars.splice(colors.indexOf('Ice Cream'), 1);

//to remove the last element
cars.pop();
Posted by: Guest on January-17-2021
3

js remove element from array

const array = [2, 5, 9];

console.log(array);

const index = array.indexOf(5);
if (index > -1) {
  array.splice(index, 1);
}
// array = [2, 9]
console.log(array);
Posted by: Guest on August-21-2020
5

js remove item array

let originalArray = [1, 2, 3, 4, 5];

let filteredArray = originalArray.filter((value, index) => index !== 2);
Posted by: Guest on November-17-2020

Code answers related to "javascript array remove index"

Code answers related to "Javascript"

Browse Popular Code Answers by Language