set.last()

Get the last element of a Set.

Signature

last() => A | Null

Description

Returns the last element of the Set. The method reverses the Set and gets the first item.

Parameters

None

Return value

One of:

Type Description

Generic

Last element of the Set.

Null

Returned 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!