# Check if an array contains a value matching some criterias

True when at least one item satisfies the predicate.

Canonical: https://1loc.dev/validator/check-if-an-array-contains-a-value-matching-some-criterias/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Usage lines executed in Node.js 22 and headless Chromium; no external services
Updated: 2026-10-28

## Implementation

```javascript
function contains(values, predicate) { return values.some(predicate); }
```

## Usage

```javascript
contains([10, 20, 30], n => n > 25); // → true
contains([10, 20, 30], n => n > 100); // → false
contains([], () => true); // → false
```

Lines marked → were executed in Node.js 22 and in headless Chromium, and each result was compared with the value shown. Lines marked e.g. are illustrative.

## Limits

- some stops at the first match and returns false for an empty array, as the last line shows.
- The predicate also receives the index and the array; wrap functions with optional parameters, as in Create a function that accepts a single argument.

The function does not validate its arguments. Add checks where it receives untrusted input.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/check-if-an-array-contains-a-value-matching-some-criterias.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: chety, nemanjapesic, 31piy, aethernet
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Documented as a reference with executed usage lines. Original MDX retained as inert source evidence.
