Returns the number of elements in the given array.

Type signature

<T>(xs: T[]) => number

Examples

length([true, 1]);
// ⇒ 2
Try in REPL
length([1, 2, 3]);
// ⇒ 3
Try in REPL
length([]);
// ⇒ 0
Try in REPL

Questions

  • How to check an array's length?
  • How to compute an array's length?
  • How to check the size of an array?
  • How to check the number of elements in an array?

TypeScript sourceJavaScript source