This commit is contained in:
Angelos Chalaris
2017-12-18 15:50:56 +02:00
parent c30efa3d38
commit 4a8f6b83a9
2 changed files with 4 additions and 4 deletions

View File

@ -446,8 +446,8 @@ Omit the second argument, `n`, to get the first element of the array.
```js
const nthElement = (arr, n=0) => (n>0? arr.slice(n,n+1) : arr.slice(n))[0];
// nth(['a','b','c'],1) -> 'b'
// nth(['a','b','b']-2) -> 'a'
// nthElement(['a','b','c'],1) -> 'b'
// nthElement(['a','b','b'],-3) -> 'a'
```
[⬆ back to top](#table-of-contents)