How to add one element to the beginning of an array in JavaScript

1 Answer

0 votes
let arr = ["javascript", "java", "c", "c++", "c#"];
 
arr.unshift("php");
   
console.log(arr); 
  
  
 
  
/*
run:
  
["php", "javascript", "java", "c", "c++", "c#"]
  
*/

 



answered Sep 12, 2022 by avibootz
...