Question 4
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log(null == 0, null >= 0, undefined == 0, undefined >= 0);
- A false false false false
- B true true false false
- C false true false false Correct
- D false true false true
Correct Answer: Option C
== never converts null/undefined to numbers. Relational operators convert null to 0 (0 >= 0 is true) and undefined to NaN (every comparison with NaN is false).
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!