How to remove specific element from an array in TypeScript

1 Answer

0 votes
const arr = ['typescript', 'php', 'python', 'c', 'c++', 'php'];
 
const index = arr.indexOf('python');
  
if (index !== -1) {  
    arr.splice(index, 1);
}
 
console.log(arr); 
   
   
     
       
       
/*
run:
       
["typescript", "php", "c", "c++", "php"] 
       
*/

 



answered Jul 4, 2022 by avibootz

Related questions

1 answer 124 views
2 answers 264 views
1 answer 155 views
1 answer 152 views
...