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"
答案 0 :(得分:63)
这应删除第一个元素,然后您可以返回剩余的:
var myarray = ["item 1", "item 2", "item 3", "item 4"];
myarray.shift();
alert(myarray);

正如其他人所建议的那样,你也可以使用slice(1);
var myarray = ["item 1", "item 2", "item 3", "item 4"];
alert(myarray.slice(1));

答案 1 :(得分:4)
试试这个
(Get-WmiObject Win32_OperatingSystem -ComputerName $vmName).name
答案 2 :(得分:2)
为什么不使用ES6?
var myarray = ["item 1", "item 2", "item 3", "item 4"];
const [first, ...rest] = myarray;
console.log(rest)
答案 3 :(得分:0)
这可以用lodash _.tail
一行完成:
var arr = ["item 1", "item 2", "item 3", "item 4"];
console.log(_.tail(arr));
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js"></script>
答案 4 :(得分:-1)
您可以使用array.slice(0,1)//删除第一个索引并返回数组。