underscore.js _.first[Array]
2012-04-15 22:12
453 查看
_.first(array, )Alias: head
Returns the first element of an array. Passing n will return the first n elements of the array
返回数组的第一个元素. 别名head
_.first([5, 4, 3, 2, 1]); => 5
源码:
_.first = _.head = _.take = function(array, n, guard) { return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; };
相关文章推荐
- underscore.js _.flatten[Array]
- underscore.js _without [Array]
- underscore.js _.union[Array]
- underscore.js _.intersect[Array]
- underscore.js _.difference[Array]
- underscore.js _uniq[Array]
- underscore.js _.zip[Array]
- underscore.js _indexOf[Array]
- underscore.js _.lastIndexOf[Array]
- underscore.js _range[Array]
- underscore.js _.initial[Array]
- underscore.js _last[Array]
- underscore.js _reset[Array]
- Underscore.js 中 _.throttle 和 _.debounce 的差异
- Underscore.js 入门
- Underscore.js 1.8.3
- Underscore.js 入门-常用方法介绍
- Underscore.js-template模板
- underscore.js _.isEmpty(Object)
- underscore.js _isUndefined[Object]