Hooks
Functions
reoderArray
reorderArray function takes an array and reorders its elements by moving an item from one index to another.
Example
import reorderArray from '@/utils/reorderArray';
const myList = ['apple', 'banana', 'cherry', 'date'];
const reorderedList = reorderArray(myList, 1, 3);
// output: ['apple', 'cherry', 'date', 'banana']Params
| param | Description | Type | Default |
|---|---|---|---|
| list | The array to be reordered. This can be an array of any type (T is a generic type). | T[] | - |
| startIndex | The index of the element in the array that you want to move. | number | - |
| endIndex | The target index where the element should be placed. | number | - |
Return
| return | Description | Type | Default |
|---|---|---|---|
| result | A new array with the element reordered from startIndex to endIndex. | T[] | - |