Skip to content

moveWithin$

Subhajit Sahu edited this page Mar 15, 2020 · 14 revisions

Moves part of array within.

array.moveWithin$(x, j, [i], [I]);
// x: an array
// j: insert index
// i: delete start index (0)
// I: delete end index   (x.length)
// --> x
const array = require('extra-array');

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

array.moveWithin$(a, 3, 1);
// [1, 2, 3, 2, 3]

array.moveWithin$(a, 3, 1, 2);
// [1, 2, 3, 2, 5]

references

Clone this wiki locally