Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/nth

Index

References

Functions

References

Renames and re-exports nth

Functions

  • nth<T>(n: number, list: ArrayLike<T>): T
  • nth(n: number): <T>(list: ArrayLike<T>) => T
  • Returns the nth element of the given array. If n is negative the element at index length + n is returned.

    example
     var list = ['foo', 'bar', 'baz', 'quux'];
    nth(1, list); //=> 'bar'
    nth(2, list); //=> 'baz'
    nth(-1, list); //=> 'quux'
    nth(-99, list); //=> undefined

    Type parameters

    • T

    Parameters

    • n: number
    • list: ArrayLike<T>

    Returns T

  • Returns the nth element of the given array. If n is negative the element at index length + n is returned.

    example
     var list = ['foo', 'bar', 'baz', 'quux'];
    nth(1, list); //=> 'bar'
    nth(2, list); //=> 'baz'
    nth(-1, list); //=> 'quux'
    nth(-99, list); //=> undefined

    Parameters

    • n: number

    Returns <T>(list: ArrayLike<T>) => T

      • <T>(list: ArrayLike<T>): T
      • Type parameters

        • T

        Parameters

        • list: ArrayLike<T>

        Returns T

Generated using TypeDoc