set.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

// `toSet()` converts an Array to a Set.
let set = [1, 2].toSet()
set.last()
2

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!