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.

    5.11.0

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