array-nth-last
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

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

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

Readme

Keywords

Package Sidebar

Install

npm i array-nth-last

Weekly Downloads

1

Version

0.3.1

License

MIT

Unpacked Size

1.36 kB

Total Files

5

Last publish

Collaborators

  • joakimunge