-
Notifications
You must be signed in to change notification settings - Fork 1
index
Subhajit Sahu edited this page Feb 3, 2021
·
21 revisions
Get zero-based index for element in iterable.
Similar: index, indexRange, size, isEmpty.
function index(x, i)
// x: an iterable
// i: index (-ve: from right)
const xiterable = require('extra-iterable');
var x = [2, 4, 6, 8];
xiterable.index(x, 1);
// → 1
xiterable.index(x, -1);
// → 3
xiterable.index(x, -10);
// → 0