Courses / JavaScript
24. Array.prototype.indexOf()
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
1 min read Chapter 24 of 99
JavaScript
Array.prototype.indexOf()
Array.prototype.indexOf() finds the first index of a specified element in an array.
"I need to check if an item exists in my list and where it is."
The `indexOf` method returns the first index of a specified element in an array, or -1 if it is not found. It's a quick way to determine the position of an element.
"I need to check if an item exists in my list and where it is."
The `indexOf` method returns the first index of a specified element in an array, or -1 if it is not found. It's a quick way to determine the position of an element.