• Returns the element at a specified index in a sequence or throws if the index is out of range. A negative index can be used to get element starting from the end.

    Example

    const indexZero = elementAt([1, 2, 3], 0); // Will be 1
    const willBeNull = elementAt([1, 2, 3], 10); // Will throw.
    const last = elementAt([1, 2, 3], -1); // 3

    Typeparam

    TSource The type of the source iterable.

    Returns

    The element at the specified position in the source sequence.

    Type Parameters

    • TSource

    Parameters

    • src: Iterable<TSource>

      The source iterable.

    • index: number

      The zero-based index of the element to retrieve.

    Returns TSource

Generated using TypeDoc