ES6 - 数组方法 shift()



shift()方法从数组中移除第一个元素并返回该元素。

语法

array.shift();    

返回值

返回从数组中移除的单个值。

示例

var arr = [10, 1, 2, 3].shift(); 
console.log("Shifted value is : " + arr )   

输出

Shifted value is : 10 
广告
© . All rights reserved.