take-last

Returns a new shallow copy of the last n elements taken from the end of the given array. When list.length < n the list returned contain list.length elements.

Usage no npm install needed!

<script type="module">
  import takeLast from 'https://cdn.skypack.dev/take-last';
</script>

README

take-last

Returns a new shallow copy of the last n elements taken from the end of the given array. When list.length < n the list returned contain list.length elements.

Build Status Code Climate js-standard-style

npm install take-last --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads David

Overview

Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false.

API Example

Pointful
var last = require('take-last')
last(2, ['a', 'b', 'c'])
//=> ['b', 'c']
Pointfree Style
var last = require('take-last')
var list = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'] ]

list.map(last(1))
//=> [['c'], ['f'], ['i']]

API

last(n, list)

arguments
  • n (number) Number of elements to take from the end of the list.
  • list (array) Array to extract elements from.
returns
  • (array) Returns copy of the last n elements taken from the end of list.

Related

Alternatives

Contributing

SEE: contributing.md

Licenses

GitHub license