Function arrLast

  • Returns the last element of an array. Throws an error if the array is empty.

    Type Parameters

    • T

      The type of elements in the array.

    Parameters

    • array: T[]

      The array to get the last element from.

    Returns T

    The last element of the array.

    Throws

    If the array is empty.

    Example

    const numbers = [1, 2, 3, 4, 5];
    const lastNumber = arrLast(numbers);
    //=> 5

Generated using TypeDoc