How to replace the first element of an array in JavaScript

1 Answer

0 votes
const arr = ['javascript', 'typescript', 'node.js', 'c++', 'c'];
  
arr[0] = 'replaced';
  
console.log(arr); 
  
    
    
    
    
/*
run:
    
["replaced", "typescript", "node.js", "c++", "c"]
    
*/

 



answered Jun 12, 2022 by avibootz
...