0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【JavaScript】配列に条件に一致する値が存在するか検証する

Last updated at Posted at 2024-02-01

以下のように記述することで配列に条件に一致する値が存在するか検証できます。

const array = [1, 3, 5, 7, 9]
const test1 = num => num > 8
const test2 = num => num > 10

console.log(array.some(test1)) // true
console.log(array.some(test2)) // false

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?