Skip to main content
Module 6 · Lesson 3 of 423/32 in the course~16 min
Module lessons (3/4)

find, some, every

Lesson preview5 hands-on exercises readyJavaScript Course · Module 6 — Functional array methods

Find the first one, check whether at least one or all satisfy a predicate.

What you'll learn in this lesson

  • Find the first element or index matching a predicate with .find() and .findIndex() (with short-circuit on the first match).
  • Quickly test Boolean quantifiers (∃ with .some(), ∀ with .every()).
  • Understand skewness on empty arrays ([].some() === false, [].every() === true) and handle it explicitly.
  • Protect access to result properties of .find() via optional chaining (?.) or if controls.

Overview

The declarative search methods .find(), .some() and .every() immediately interrupt (short-circuit) as soon as the outcome is determined, avoiding scanning through the entire array unnecessarily as .filter()[0] would.

Sections covered in this lesson

  1. 1Mental model: find one vs boolean verification
  2. 2Progressive examples
  3. 3Guided laboratory
  4. 4Check for understanding
Pro Lesson · Module 6 — Functional array methods

Unlock "find, some, every" and the full JavaScript Course curriculum

Find the first one, check whether at least one or all satisfy a predicate.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in JavaScript Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.