take-last

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
3
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Returns a new list containing the last `n` elements of the given list.
1 contributor
Install take-last as a package?
Copied
npm i @bit/justin-capalbo.ramda.take-last
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
takeLast (
n:Number,
xs:Array
) : Array

Returns a new list containing the last n elements of the given list. If n > list.length, returns a list of list.length elements.

Example
R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
     R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
     R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
     R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
     R.takeLast(3, 'ramda');               //=> 'mda'
Arguments
n: Number

The number of elements to return.

xs: Array

The collection to consider.

Returns
Array

Help and resources