Answers for "typescript remove item from array with index"

4

array remove index from array

const array = [2, 5, 9];

//Get index of the number 5
const index = array.indexOf(5);
//Only splice if the index exists
if (index > -1) {
  //Splice the array
  array.splice(index, 1);
}

//array = [2, 9]
console.log(array);
Posted by: Guest on September-10-2020
0

typescript remove element from array

let foo_object // Item to remove
this.foo_objects = this.foo_objects.filter(obj => obj !== foo_object);
Posted by: Guest on February-26-2021

Code answers related to "typescript remove item from array with index"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language