How to remove N elements from array start from negative index forward in TypeScript

1 Answer

0 votes
const arr = ['typescript', 'php', 'python', 'c', 'c#', 'c++', 'go', 'css', 'java'];
   
const index = -3;
const N = 2
  
arr.splice(index, N);
   
console.log(arr); 
   
   
   
   
/*
run:

["typescript", "php", "python", "c", "c#", "c++", "java"] 
   
*/

 



answered Jul 7, 2022 by avibootz
...