Skip to content
Subhajit Sahu edited this page Dec 8, 2022 · 12 revisions

Keep first n entries only (default order).

Alternatives: take, take$.
Similar: take, drop.


function take(x, n)
// x: an object
// n: number of entries [1]
const object = require('extra-object');

var x = {a: 1, b: 2, c: 3, d: 4, e: 5};
object.take(x, 2);
// → { a: 1, b: 2 }

object.take(x, 3);
// → { a: 1, b: 2, c: 3 }


References

Clone this wiki locally