moveItem

Type:Function
Status:stable
Platform:jsnode
@blackbyte.sugar.shared.array

This function allows you to move an item to another place in the array

Params

  1. array*-Array

    The array to process

  2. from*-any|integer

    Either the element itself that you want to move, or the index of the element you want to move

  3. to*-any|integer

    Either the element itself where you want to move the first one, or the index of the element you want to move your element to

Return

  1. -Array

    The processed array

Example

import { moveItem } from '@blackbyte/sugar/array';
const myArray = ['hello','world','something'];
moveItem(myArray, 0, 1); // ['world','hello','something']