distinct()

Get unique elements.

Signature

distinct(): Array<T>

Description

The distinct() method returns the unique elements in the array.

Distinct accepts only an ordered Array as input. This means that distinct() can be used on the results returned by an index provided the result array hasn’t been reordered and map() or flatMap() havn’t been called on the array.

There is no limit on the size of the array that the distinct() method can be run on.

The source array isn’t changed.

Parameters

None

Return value

Type Description

Array

Unique elements in the array.

Examples

[1, 1, 2, 3, 3].distinct()
[
  1,
  2,
  3
]

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!