JS Utils Kit
    Preparing search index...

    Function lastElement

    • Returns the last element of an array.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        A list of elements.

      Returns T | undefined

      The last element, or undefined if the array is empty

      lastElement([1, 2, 3]);
      // 3

      lastElement([]);
      // undefined