How to remove first and last element from an array in JavaScript

1 Answer

0 votes
let arr = ["javascript", "php", "c", "c++", "c#", "python"];
 
arr.shift(); // removes first
arr.pop();  // removes last
 
console.log(arr);
 
     
     
     
/*
run:
     
["php", "c", "c++", "c#"] 
     
*/

 



answered Feb 8, 2021 by avibootz
edited Feb 8, 2021 by avibootz
...