What is the purpose of `Array.prototype.indexOf()` vs `Array.prototype.findIndex()`?

JavaScript Professional Easy

JavaScript Professional — Easy

What is the purpose of `Array.prototype.indexOf()` vs `Array.prototype.findIndex()`?

Key points

  • `indexOf()` uses strict equality for value comparison
  • `findIndex()` allows for more complex search conditions
  • `indexOf()` returns the index of the first occurrence
  • `findIndex()` returns the index of the first element that satisfies the condition

Ready to go further?

Related questions