-
Notifications
You must be signed in to change notification settings - Fork 1
splice
Subhajit Sahu edited this page Feb 3, 2021
·
21 revisions
Remove or replaces existing values.
function splice(x, i, n, ...vs)
// x: an iterable
// i: remove index [0]
// n: number of values to remove [rest]
// vs: values to insert
const xiterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
[...xiterable.splice(x, 2)];
// → [1, 2]
[...xiterable.splice(x, 2, 2)];
// → [1, 2, 5]
[...xiterable.splice(x, 2, 2, 30, 40)];
// → [1, 2, 30, 40, 5]