Skip to content
Subhajit Sahu edited this page May 19, 2020 · 15 revisions

Extracts given number of values from array. 🏃 📼 📦 🌔 📒

Alternatives: take, takeWhile.
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