to remove first and last element in array
Solution 1:
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.
Solution 2:
Creates a 1 level deep copy.
fruits.slice(1, -1)
Let go of the original array.
Thanks to @Tim for pointing out the spelling errata.
Solution 3:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var newFruits = fruits.slice(1, -1);
console.log(newFruits); // ["Orange", "Apple"];
Here, -1 denotes the last element in an array and 1 denotes the second element.