- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5
splice
        Subhajit Sahu edited this page May 3, 2023 
        ·
        26 revisions
      
    Remove or replace existing values.
function splice(x, i, n, ...vs)
// x:  an array
// i:  remove index
// n:  number of values to remove [rest]
// vs: values to insertconst xarray = require('extra-array');
var x = [1, 2, 3, 4, 5];
xarray.splice(x, 2);
// → [ 1, 2 ]
xarray.splice(x, 2, 2);
// → [ 1, 2, 5 ]
xarray.splice(x, 2, 2, 30, 40);
// → [ 1, 2, 30, 40, 5 ]