![]() |
VOOZH | about |
The last() method is used to return the last element from the collection that satisfy the given truth test.
Syntax:
collect(array).last(callback)
Parameters: The collect() method takes one argument that is converted into the collection and then last() method is applied on it. The last() method holds the callback function.
Return Value: This method returns the last element from the collection that satisfy the given truth test.
Below example illustrate the last() method in collect.js:
Example 1:
Output:
50
Example 2:
Output:
{ name: 'Rahul', dob: '19-08-96', section: 'B', score: 77 }