File size: 287 Bytes
84c1942 | 1 2 3 4 5 6 7 8 9 10 11 | export function moveItem(array, oldIndex, newIndex) {
if (newIndex >= array.length) {
let k = newIndex - array.length;
while (k-- + 1) {
array.push(undefined);
}
}
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
return array; // for testing purposes
}
|