Skip to content
Subhajit Sahu edited this page Mar 14, 2020 · 26 revisions

Removes or replaces existing values.

array.splice(x, i, [n], ...vs);
// x:  an array
// i:  remove index
// n:  no. of values to remove
// vs: values to insert
// --> [0->i, vs, i+n->I]
const array = require('extra-array');

var a = [1, 2, 3, 4, 5];
array.splice(a, 2);
// [1, 2]

array.splice(a, 2, 2);
// [1, 2, 5];

array.splice(a, 2, 2, 30, 40);
// [1, 2, 30, 40, 5];

references

Clone this wiki locally