uft
    Preparing search index...

    Function at

    • Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array-like.

      Type Parameters

      • T extends ArrayLike<unknown>

      Parameters

      • array: T | null | undefined

        The array-like to search.

      • index: number

        The index of the item to return.

      Returns T[number] | undefined

      The item at the given index.

      at(["a", "b"], 0) // "a"
      at(["a", "b"], 1) // "b"
      at(["a", "b"], 9) // undefined
      at(["a", "b"], -1) // "b"
      at(["a", "b"], -2) // "a"
      at(["a", "b"], -9) // undefined

      at("bar", 2) // "r"
      at("bar", -1) // "r"

      at(null, 0) // undefined
      at(undefined, 1) // undefined