Array.prototype.indexOf

Array.prototype.indexOf

Array.prototype.indexOf is a method that can be used to find the index of a given value within an array.

If successful the method will return the index, if not then the method will return -1.

The method indexOf accepts a value as an argument. For more complex cases, such as finding an object, <a href="/definition/array.prototype.findindex/">Array.prototype.findIndex</a> might be needed.

Related topics

© 2024 MWXYZ