Question 10
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const values = [1, NaN, 3];
console.log(values.includes(NaN), values.indexOf(NaN));
- A true 1
- B false -1
- C true -1 Correct
- D false 1
Correct Answer: Option C
includes uses SameValueZero (NaN equals NaN); indexOf uses === (NaN never equals anything).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!