Takes up to a given count of elements.

Type signature

(count: number) => (xs: any[]) => any[]

Examples

take(2)([1, 2, 3, 4, 5]);
// ⇒ [1, 2]
Try in REPL
take(10)([1, 2, 3, 4, 5]);
// ⇒ [1, 2, 3, 4, 5]
Try in REPL

Questions

  • How to get the first N number of elements from an array?

TypeScript sourceJavaScript source