Moves an item within array from fromIndex to toIndex, shifting other elements to accommodate. The array is mutated in place.
array
fromIndex
toIndex
The item type.
The array to mutate.
Current zero-based index of the item to move.
Desired zero-based index for the item.
const items = ['a', 'b', 'c', 'd'];moveItemInArray(items, 0, 2);// items → ['b', 'c', 'a', 'd'] Copy
const items = ['a', 'b', 'c', 'd'];moveItemInArray(items, 0, 2);// items → ['b', 'c', 'a', 'd']
Moves an item within
arrayfromfromIndextotoIndex, shifting other elements to accommodate. The array is mutated in place.