- Notifications
You must be signed in to change notification settings - Fork 1
slice
Subhajit Sahu edited this page Feb 3, 2021 · 23 revisions
Get part of an iterable.
function slice(x, i, I) // x: an iterable // i: start index (-ve: from right) [0] // I: end index (-ve: from right) [END]const xiterable = require('extra-iterable'); var x = [1, 2, 3, 4, 5]; [...xiterable.slice(x, 2)]; // → [3, 4, 5] [...xiterable.slice(x, 2, 4)]; // → [3, 4] [...xiterable.slice(x, -3, -1)]; // → [3, 4]