Skip to content
JavaScript·Advanced·Conceptual·1 min read

Does Array.prototype.includes use === or something else to find a match?

Short interview answer

It uses SameValueZero, which behaves like === except it treats NaN as equal to itself — this is why arr.includes(NaN) can find NaN in an array while arr.indexOf(NaN) cannot, since indexOf uses strict equality.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Equality and type coercion

Related questions