Function atW

Returns the element at the specified position in the source array.

It produces the same wide type as the "at" method of the source array.

at

at(0)([1, 2, 3]); // 1 with type number
at(1)([1, 2, 3] as const); // 2 with literal type 2
at(-1)([1, 2, 3] as const); // 3 with literal type 3
  • Parameters

    • position: number

    Returns (<S>(source: S) => undefined | S[number])

      • <S>(source): undefined | S[number]
      • Type Parameters

        • S extends readonly unknown[]

        Parameters

        • source: S

        Returns undefined | S[number]