Returns new copies of source and target with the item at fromIndex removed from source and inserted into target at toIndex. The original arrays are not modified.
source
target
fromIndex
toIndex
The item type.
The array to remove from (not mutated).
Zero-based index of the item to remove from source.
The array to insert into (not mutated).
Zero-based index at which to insert into target.
A tuple [newSource, newTarget] with the transfer applied.
[newSource, newTarget]
const [src, tgt] = moveItemToArrayPure( ['a', 'b', 'c'], 1, ['x', 'y'], 1,);// src → ['a', 'c']// tgt → ['x', 'b', 'y'] Copy
const [src, tgt] = moveItemToArrayPure( ['a', 'b', 'c'], 1, ['x', 'y'], 1,);// src → ['a', 'c']// tgt → ['x', 'b', 'y']
Returns new copies of
sourceandtargetwith the item atfromIndexremoved fromsourceand inserted intotargetattoIndex. The original arrays are not modified.