Skip to content
Subhajit Sahu edited this page Feb 2, 2021 · 15 revisions

Keeps first n values only. 🏃 📼 📦 🌔 📒

Alternatives: take, takeRight, takeWhile, takeWhileRight.
Similar: take, drop.


array.take(x, [n]);
// x: an array
// n: number of values (1)
const array = require('extra-array');

var x = [1, 2, 3, 4, 5];
array.take(x, 2);
// [ 1, 2 ]

array.take(x, 3);
// [ 1, 2, 3 ]


References

Clone this wiki locally