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