nth
Modified on Mon, 07 Aug 2023
Description
Get the element at index `n` of `array`. If `n` is negative, the nth element from the end is returned.
Syntax
nth(array, n)
Parameters
Input Parameter | Type | Description |
---|---|---|
array | Array | The array to query. |
n | number | The index of the element to return. |
Return value
Type |
---|
any |
Sample
Example | Result | Description |
---|---|---|
nth(['a', 'b', 'c', 'd'], 2) | 'c' | Returns 2nd index (3rd) value. |
nth(['a', 'b', 'c', 'd'], -1) | 'd' | Returns 1st value from the end |
To view all the List functions, click here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article