Options
All
  • Public
  • Public/Protected
  • All
Menu

Module nth

Index

References

Functions Array

References

Renames and re-exports nth

Array Functions

  • nth<T>(array: T[], n?: number): T
  • Gets the element at index n of array. If n is negative, the nth element from the end is returned.

    since

    5.7.0

    example
    const array = ['a', 'b', 'c', 'd']

    nth(array, 1)
    // => 'b'

    nth(array, -2)
    // => 'c'

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to query.

    • n: number = 0

      The index of the element to return.

    Returns T

    Returns the nth element of array.