您的位置:首页 > Web前端 > JavaScript

underscore.js _.initial[Array]

2012-04-15 22:24 459 查看
initial
_.initial(array,
)

Returns everything but the last entry of the array. Especially useful on the arguments object. Pass n to exclude the last n elements from the result.

返回数组的所有元素,最后一个元素除外

_.initial([5, 4, 3, 2, 1]);
=> [5, 4, 3, 2]  


源码:

_.initial = function(array, n, guard) {
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
};


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: