Answers for "delete array element if we have an index in js"

36

javascript remove from array by index

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

Code answers related to "delete array element if we have an index in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language