How to remove the first item from an array in JavaScript

1 Answer

0 votes
const arr = ["javascript", "php", "c++", "python"];

arr.shift();

arr.forEach(function(item, index, array) {
  document.write(item + " " + index + "<br />");
});



/*
run:
      
php 0
c++ 1
python 2
    
*/

 



answered Nov 2, 2019 by avibootz

Related questions

1 answer 175 views
1 answer 173 views
4 answers 289 views
1 answer 187 views
1 answer 196 views
1 answer 211 views
1 answer 196 views
...