initial_.initial(array, [n]) 
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));
  };

  

 

posted on 2012-04-15 22:24  himanhimao  阅读(284)  评论(0编辑  收藏  举报