How to replace element in an array in specific index with TypeScript

1 Answer

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

 



answered Jul 5, 2022 by avibootz
...