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 167 views
1 answer 163 views
4 answers 274 views
1 answer 176 views
1 answer 188 views
1 answer 199 views
1 answer 186 views
...