@pengzhanbo/utils - v3.7.3
    Preparing search index...

    Function move

    • Move item in an array, change the original array.

      移动数组中的项,此方法会改变原数组。

      Type Parameters

      • T

        The type of elements in the array / 数组元素的类型

      Parameters

      • arr: T[]

        the array / 数组

      • from: number

        the index of the item to move. 要移动的项的索引

      • to: number

        the index to move to. 要移动到的索引

      Returns T[]

      the array with the item moved. 返回移动后的数组

      This function mutates the original array in place using Array.prototype.splice. It does not create a copy.

      此函数会通过 Array.prototype.splice 直接修改原数组,不会创建副本。

      move([1, 2, 3], 0, 2) // => [3, 1, 2]