Skip to content

any

Summary

True if given predicate returned logical true for at least one element of the list.

Tip

This function is curried.

Examples

Check that a list does contain at least one 'x'.

1
2
3
4
5
6
7
const has_x = any(eq('x'));

has_x(['a','b','c']);            //=> false
has_x(['a','x','c']);            //=> true

has_x({m: 'a', n: 'b', o: 'c'}); //=> false
has_x({m: 'a', n: 'x', o: 'c'}); //=> true

Parameters

Name Type Description
pred function Predicate
xs Array or Object List of values

Return

boolean