set.any()

Test if any Set member passes the test of the given function.

Signature

any(predicate: T => Boolean | Null) => Boolean

Description

The any() method tests if any element passes the test of the given function.

Parameters

Parameter Type Required Description

predicate

Function

Yes

Anonymous Function that applies tests the Set elements.

Predicate parameters: None

Return value

Type Description

Boolean

Status of predicate applied to every Set element:
true = At least one element passes the test.
false = No elements pass the test. An empty Set returns false.

Examples

// `toSet()` converts an Array to a Set.
let set = [1, 2, 3].toSet()
set.any(v => v == 2)
true

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!