Skip to content

splice$

wolfram77 edited this page Mar 31, 2020 · 20 revisions

Removes or replaces existing values.

Alternatives: default, update.

array.splice$(x, i, [n], ...vs);
// x:  an array (updated)
// i:  remove index
// n:  number of values to remove (rest)
// vs: values to insert
// --> removed
const array = require('extra-array');

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

x;
// [ 1, 2 ]

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

var x = [1, 2, 3, 4, 5];
array.splice$(x, 2, 2, 30, 40);
// [ 3, 4 ]   (x = [ 1, 2, 30, 40, 5 ])

references

Clone this wiki locally