@nevware21/ts-utils
    Preparing search index...

    Function arrShuffle

    • The arrShuffle() method returns a new array with elements randomly shuffled. Uses the Fisher-Yates shuffle algorithm for uniform randomization.

      Type Parameters

      • T

        Identifies the base type of array elements

      Parameters

      • theArray: ArrayLike<T>

        The array or array-like object to shuffle

      Returns T[]

      A new array with elements in random order

      0.14.0

      arrShuffle([1, 2, 3, 4, 5]);  // e.g., [3, 1, 5, 2, 4]
      arrShuffle(["a", "b", "c"]); // e.g., ["c", "a", "b"]
      arrShuffle([1]); // [1]
      arrShuffle([]); // []

      // Array-like objects
      arrShuffle({ length: 3, 0: "x", 1: "y", 2: "z" }); // e.g., ["z", "x", "y"]