@newdash/newdash
Version:
javascript/typescript utility library
24 lines (23 loc) • 508 B
TypeScript
/**
* Gets the element at index `n` of `array`. If `n` is negative, the nth
* element from the end is returned.
*
* @since 5.7.0
* @category Array
* @param array The array to query.
* @param n The index of the element to return.
* @returns Returns the nth element of `array`.
* @example
*
* ```js
* const array = ['a', 'b', 'c', 'd']
*
* nth(array, 1)
* // => 'b'
*
* nth(array, -2)
* // => 'c'
* ```
*/
export declare function nth<T>(array: Array<T>, n?: number): T;
export default nth;