JavaScript · Junior · Question 27 of 75

What do [NaN].includes(NaN) and [NaN].indexOf(NaN) return?

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.

Further reading

Problem with a question

JavaScript · Junior · question 27

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz