typescript remove element from array

Solutions on MaxInterview for typescript remove element from array by the best coders in the world

showing results for - "typescript remove element from array"
Mariana
13 May 2016
1const index = myArray.indexOf(key, 0);
2if (index > -1) {
3   myArray.splice(index, 1);
4}
Leni
05 Apr 2019
1const index = array.indexOf(item);
2if (index !== -1) array.splice(index, 1);
Serena
12 Aug 2016
1let foo_object // Item to remove
2this.foo_objects = this.foo_objects.filter(obj => obj !== foo_object);
3
Lisa
19 Apr 2016
1myArray.splice(index, 1); // insert index and then amount to remove 
2						  // from that index
3
Carla
24 Apr 2020
1
2    
3    var ar = [1, 2, 3, 4, 5, 6];
4    
5    ar.pop(); // returns 6
6    
7    console.log( ar ); // [1, 2, 3, 4, 5]
8
similar questions
queries leading to this page
typescript remove element from array