How to remove the last 3 elements from an array in TypeScript

1 Answer

0 votes
const arr: Array<string> = ['javascript', 'typescript', 'php', 'node.js', 'c++', 'c', 'c#'];
  
arr.splice(arr.length - 3, 3);
   
console.log(arr); 
    
    
    
    
/*
run:
    
["javascript", "typescript", "php", "node.js"] 
    
*/
 
 

 



answered Aug 14, 2022 by avibootz
...