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


last($numItems = 1) -> any


Return the last item or the last $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, if $numItems is greater than the size of the list, it will return as many items as possible.

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

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

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

See Also