var myarray = ["item 1", "item 2", "item 3", "item 4"];
//removes the first element of the array, and returns that element.
alert(myarray.shift());
//alerts "item 1"
//removes the last element of the array, and returns that element.
alert(myarray.pop());
//alerts "item 4"
- 如何删除第一个数组但返回数组减去第一个元素
- 在我的示例中,
"item 2", "item 3", "item 4"
当我删除第一个元素时我应该得到
alert(array.slice(1))
或array.shift(); alert(array);