Answers for "js remove array entry"

49

javascript remove from array by index

//Remove specific value by index
array.splice(index, 1);
Posted by: Guest on May-06-2020
0

javascript remove element from array

const array = [2, 5, 10];

console.log(array);

const index = array.indexOf(5);
if (index > -1) {
  array.splice(index, 1); // 2nd parameter means remove one item only
}

// array = [2, 9]
console.log(array); 
 Run code snippetHide results
Posted by: Guest on May-05-2022

Code answers related to "js remove array entry"

Code answers related to "Javascript"

Browse Popular Code Answers by Language