Skip to content
Subhajit Sahu edited this page Feb 3, 2021 · 23 revisions

Gets part of an iterable. 🏃 📼 📦 🌔 📒


iterable.slice(x, [i], [I]);
// x: an iterable
// i: start index (-ve: from right) (0)
// I: end index (-ve: from right) (X)
const iterable = require("extra-iterable");

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

[...iterable.slice(x, 2, 4)];
// [ 3, 4 ]

[...iterable.slice(x, -3, -1)];
// [ 3, 4 ]


References

Clone this wiki locally