How to remove first and last element in an array?
For example:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
Expected output array:
["Orange", "Apple"]
fruits.shift(); // Removes the first element from an array and returns only that element. fruits.pop(); // Removes the last element from an array and returns only that element.
See all methods for an Array.
1.4m articles
1.4m replys
5 comments
57.0k users