Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Linear scan from fromIndex using strict equality to find the first matching element. Handle negative fromIndex by computing the offset from the end. Return the index on the first match, or -1 if the value is not found in the remaining elements.
IndexOf returns the numeric position of the first occurrence, enabling operations like removing duplicates, finding positions for splice, or checking existence before includes was introduced.
Updated Feb 2026