Version: v0.7.0 - Beta.  We welcome contributors & feedback.


first($numItems = 1) -> any


Return the first item or the first $numItems items in the List.

If the list is empty and $numItems is 1, it will return the default value of the list (e.g. empty string '').

Otherwise, $numItems is greater than the size of the list, it will return as many items as possible.

['a', 'b', 'c'].first()
//= 'a'

['a', 'b', 'c'].first(2)
//= ['a', 'b']

['a', 'b', 'c'].first(5)
//= ['a', 'b', 'c']

See Also