Returns a new array with the item at fromIndex relocated to toIndex. The original array is not modified.
fromIndex
toIndex
The item type.
The source array (not mutated).
Current zero-based index of the item to move.
Desired zero-based index for the item.
A new array with the item relocated.
const result = moveItemInArrayPure(['a', 'b', 'c', 'd'], 0, 2);// result → ['b', 'c', 'a', 'd'] Copy
const result = moveItemInArrayPure(['a', 'b', 'c', 'd'], 0, 2);// result → ['b', 'c', 'a', 'd']
Returns a new array with the item at
fromIndexrelocated totoIndex. The original array is not modified.