0.2.0 • Published 5 years ago

@joakimunge/array-nth-last v0.2.0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

array-last

Tiny function to get n last entry from array

Install

$ yarn add array-last

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