-
Notifications
You must be signed in to change notification settings - Fork 5
take
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 ]