如何删除数组中的第一个和最后一个元素?
例如:
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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句