Category
The iterable to take elements from
Optional
take: undefinedThe first element of the iterable
Iterable
first([1, 2, 3]); // 1
Category
Get the first n
elements from an iterable.
Time complexity: O(n)
Space complexity: O(n)
The iterable to take elements from
The number of elements to take from the iterable
The first take
elements of the iterable
Iterable
[...first([1, 2, 3], 1)]; // [1]
[...first([1, 2, 3], 2)]; // [1, 2]
Get the first element from an iterable.
Time complexity: O(1)
Space complexity: O(1)