_.first(array, [n])
Alias: head
Returns the first element of an array. Passing n will return the first n elements of the array
返回数组的第一个元素. 别名head
1 _.first([5, 4, 3, 2, 1]); 2 => 5
源码:
_.first = _.head = _.take = function(array, n, guard) { return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; };