How to remove item from the end of an array in JavaScript

1 Answer

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

arr.pop();

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



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

 



answered Nov 2, 2019 by avibootz

Related questions

1 answer 178 views
1 answer 180 views
4 answers 273 views
1 answer 176 views
1 answer 164 views
1 answer 199 views
1 answer 186 views
...