last()

Get the last element in a set.

Signature

last(): Any | Null

Description

The last() method returns the last element of the set. It reverses the set and gets the first item.

Parameters

None

Return value

Type Description

Any

Last element of the set or null if the set is empty.

Examples

let iter = [1, 2]
iter.last()
2

See also

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!