TS-Scribe - v0.6.2
    Preparing search index...

    Function shuffleArray

    • Shuffles the elements of an array randomly.

      The function creates a new array and performs an in-place shuffle using the Fisher-Yates algorithm. This ensures that the shuffled array has a uniform random distribution of elements.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The input array to shuffle.

      Returns T[]

      A new array with the elements shuffled randomly.

      const shuffledArray = shuffleArray([1, 2, 3, 4, 5]);
      console.log(shuffledArray);
      // Output: A shuffled array, e.g., [4, 1, 3, 5, 2] (output will be random).