Skip to content

Mangler.last()

Robert Biro edited this page Oct 12, 2016 · 3 revisions

Returns the last item of an iterable that passes the test.

Mangler.last(collection[, test])
Parameter Type Default Description
collection Iterable The collection of values to search.
test Test {} The test expression to check against.

Returns

Returns the last item that passes the test.


If called without a test parameter, it returns the last item of the collection iterable, which could be an object, array or mangler object by default. Please note that even though an object is iterable, it is not guaranteed that its properties will be evaluated in any particular order.

For more information on test expressions, see Mangler.test().

Example

a = [1, 2, 3, 4];

Mangler.last(a);                // Returns 4
Mangler.last(a, { $lt: 4 });    // Returns 3

Learning Mangler.js

Optional Modules

Reference

Clone this wiki locally