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 255 views
1 answer 254 views
4 answers 459 views
1 answer 285 views
1 answer 278 views
1 answer 303 views
1 answer 271 views
...