Function shuffle

  • Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.

    Type Parameters

    • T

    Parameters

    • collection: Collection<T>

      The array to shuffle.

    Returns T[]

    Returns the new shuffled array.

    Since

    5.11.0

    Example

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