Array.prototype.indexOfintermediateconst arr = [1, 2, 3, 1, 2]
arr.indexOf(1) // β 0
arr.indexOf(1, 1) // β 3 (starts at index 1)Pass a fromIndex to indexOf() to skip past the first occurrence and find later ones.
The optional second argument fromIndex tells indexOf where to start searching. This lets you find subsequent occurrences after a known position.
Challenge: Implement indexOfFrom(arr, val, from) that uses arr.indexOf(val, from).
indexOfFrom([1, 2, 1, 2], 2, 2) // β 3
indexOfFrom([1, 2, 1, 2], 1, 1) // β 2