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

1 Answer

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

 



answered Jun 11, 2022 by avibootz
edited Aug 14, 2022 by avibootz
...