JavaScript · Junior · Question 27 of 75
What do [NaN].includes(NaN) and [NaN].indexOf(NaN) return?
- ✓Correct answer:
trueand-1 - 2
falseand-1 - 3
trueand0
Explanation
indexOf uses strict equality ===, and NaN !== NaN. includes uses the SameValueZero algorithm, which treats NaN as equal to itself. So includes is more reliable for checking presence.