What does `Array.prototype.find()` return when no element satisfies the condition?

JavaScript Associate Medium

JavaScript Associate — Medium

What does `Array.prototype.find()` return when no element satisfies the condition?

Key points

  • `Array.prototype.find()` returns the first element in the array that satisfies the provided testing function.
  • If no element satisfies the condition, the method returns `undefined`.
  • This is different from methods like `indexOf()` which return -1 when no match is found.

Ready to go further?

Related questions