Searching Arrays with indexOf and lastIndexOf
Description
The lastIndexOf()
method compares searchElement
to elements of the array using strict equality (the same algorithm used by the ===
operator). NaN
values are never compared as equal, so lastIndexOf()
always returns -1
when searchElement
is NaN
.
The lastIndexOf()
method skips empty slots in sparse arrays.
The lastIndexOf()
method is generic. It only expects the this
value to have a length
property and integer-keyed properties.