如何删除数组中的第一个和最后一个元素?
例如:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
预期输出数组:
["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.
关于javascript - 删除数组中的第一个和最后一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4644139/