Options
All
  • Public
  • Public/Protected
  • All
Menu

Module take

Index

Functions Array

Array Functions

  • take<T>(array: ArrayLike<T>, n?: number, guard?: any): T[]
  • Creates a slice of array with n elements taken from the beginning.

    since

    5.6.0

    example
    take([1, 2, 3])
    // => [1]

    take([1, 2, 3], 2)
    // => [1, 2]

    take([1, 2, 3], 5)
    // => [1, 2, 3]

    take([1, 2, 3], 0)
    // => []

    Type Parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array to query.

    • Optional n: number

      The number of elements to take.

    • Optional guard: any

    Returns T[]

    Returns the slice of array.