How to replace 2 elements in an array start from specific index with TypeScript

1 Answer

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

 



answered Jul 5, 2022 by avibootz
edited Jul 5, 2022 by avibootz
...