The type of elements in the array.
The input array.
The index of the element to swap from.
The index of the element to swap to.
The modified array with swapped elements.
Will throw an error if 'from' or 'to' is not a valid index in the array.
const arr = [1, 2, 3, 4, 5]
arrSwap(arr, 1, 3) //=> [1, 4, 3, 2, 5]
Generated using TypeDoc
Swaps two elements in an array. This function takes an input array and swaps the elements at the specified indices.