Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joakimunge/array-nth-last
Tiny library to get last, or nth last entry in array
https://github.com/joakimunge/array-nth-last
array array-helper function javascript npm npm-package package utility
Last synced: about 3 hours ago
JSON representation
Tiny library to get last, or nth last entry in array
- Host: GitHub
- URL: https://github.com/joakimunge/array-nth-last
- Owner: joakimunge
- Created: 2020-03-09T14:47:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T08:27:17.000Z (over 4 years ago)
- Last Synced: 2024-10-25T21:53:09.917Z (12 days ago)
- Topics: array, array-helper, function, javascript, npm, npm-package, package, utility
- Language: JavaScript
- Size: 9.77 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# array-nth-last
Tiny function to get _nth_ last entry from array
## Install
```
$ yarn add array-nth-last
```or
```
$ npm install array-nth-last --save
```## Usage
```javascript
const last = require('array-nth-last');const arr = [1, 2, 3, 4, 5];
last(arr); // => 5
last(arr, 3); // => 2
```## API
---
### last(array, n?)
Returns the _nth_ last entry from the array
#### array
Type: `Array`
The array from which to get the _nth_ entry
#### n? _optional_
Type: `number`
The desired entry of the array to return