Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The main difference between the functions indexOf and findIndex of an array is that indexOf returns the first index at which a given element can be found in the array whereas findIndex returns the index of the first element in the array that satisfies a given testing function.

So, indexOf searches for a specific element in the array and returns its index (or -1 if not found), whereas findIndex searches the array for the first element that meets a specific criteria (determined by the testing function) and returns its index (or -1 if no element satisfies the criteria).