_.nth(array, [n=0])
Gets the element at index n
of array
. If n
is negative, the nth element from the end is returned.
Since
4.11.0
Arguments
array
(Array): The array to query.[n=0]
(number): The index of the element to return.
Returns
(*): Returns the nth element of array
.
Example
var array = ['a', 'b', 'c', 'd'];_.nth(array, 1);// => 'b'_.nth(array, -2);// => 'c';
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .