typescript remove an item from array

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

showing results for - "typescript remove an item from array"
Timote
23 Feb 2017
1const index = myArray.indexOf(key, 0);
2if (index > -1) {
3   myArray.splice(index, 1);
4}
María
07 Oct 2018
1let foo_object // Item to remove
2this.foo_objects = this.foo_objects.filter(obj => obj !== foo_object);
3
Filippo
24 Oct 2018
1myArray.splice(index, 1); // insert index and then amount to remove 
2						  // from that index
3
Alejandro
09 Jun 2019
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 an item from array