How to replace element in an array in specific index with Node.js

1 Answer

0 votes
const arr = ['node.js', 'php', 'python', 'c', 'java', 'c#'];

const index = 1;
 
arr.splice(index, 1, "c++");
  
console.log(arr); 
  
  
  
  
/*
run:
  
[ 'node.js', 'c++', 'python', 'c', 'java', 'c#' ]
  
*/

 



answered Jul 5, 2022 by avibootz

Related questions

1 answer 172 views
1 answer 105 views
1 answer 128 views
...