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

    Function arrReverse

    • The arrReverse() method reverses an array in place and returns the reference to the same array. The first array element becomes the last, and the last array element becomes the first. If you want to reverse an array without modifying the original, use arrSlice() first.

      Type Parameters

      • T

      Parameters

      Returns WritableArrayLike<T>

      The reversed array (same reference as input)

      0.14.0

      const arr1 = [1, 2, 3];
      arrReverse(arr1); // [3, 2, 1]
      // arr1 is now [3, 2, 1]

      arrReverse(["a", "b", "c"]); // ["c", "b", "a"]
      arrReverse([1]); // [1]
      arrReverse([]); // []

      // Non-mutating usage
      const original = [1, 2, 3];
      const reversed = arrReverse(arrSlice(original));
      // original: [1, 2, 3], reversed: [3, 2, 1]