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

    Function shuffle

    • Array shuffling, randomly rearranging the order of elements in an array

      数组洗牌,随机打乱数组中的顺序

      Type Parameters

      • T

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

      Parameters

      • array: T[]

        The array to shuffle / 要洗牌的数组

      Returns T[]

      The shuffled array (same reference as input) / 洗牌后的数组(与输入为同一引用)

      This function mutates the original array and returns it. If you need to preserve the original array, pass a copy: shuffle([...arr]).

      此函数会修改原数组并返回它。 如果需要保留原数组,请传入副本:shuffle([...arr])

      shuffle([1, 2, 3]) // => [1, 3, 2]