The Fauna service will be ending on May 30, 2025.

For more information on the service wind down, see our announcement and the Fauna Service End-of-Life FAQ.

set.last()

Learn: Sets

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
\