NewDash

    Function take

    • Creates a slice of array with n elements taken from the beginning.

      Type Parameters

      • T

      Parameters

      • array: ArrayLike<T>

        The array to query.

      • Optionaln: number

        The number of elements to take.

      • Optionalguard: any

      Returns T[]

      Returns the slice of array.

      5.6.0

      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)
      // => []
    MMNEPVFCICPMFPCPTTAAATR