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