How to remove an item from an array by index in TypeScript

1 Answer

0 votes
const arr: string[] = ["typescript", "php", "c++", "python", "c"];
  
let index: number = 1;
let item: string[] = arr.splice(index, 1);
  
arr.forEach(function(item, index, array) {
    console.log(item + " " + index);
});
  
  
  

  
/*
run:
        
"typescript 0" 
"c++ 1" 
"python 2" 
"c 3" 
      
*/

 



answered Mar 1, 2023 by avibootz
...