Tweakr
    Preparing search index...

    Function head

    • Returns the first element of an array.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to query.

      Returns undefined | T

      The first element of the array, or undefined if the array is empty.

      head([1, 2, 3]);
      // → 1

      head([]);
      // → undefined

      1.0.0