HardType Coercion💻 Output Question

null comparison inconsistency

💡

Hint

null coerces to 0 for relational ops (>, <, >=, <=) but NOT for ==. This creates the famous null>=0 && !(null==0) quirk.

What does this output?

console.log(null > 0);
console.log(null == 0);
console.log(null >= 0);

Correct Output

false
false
true

Why this output?

Explanation: null>0: null→0, 0>0=false. null==0: false (null only equals undefined). null>=0: null→0, 0>=0=true. Famous inconsistency!

Key Insight: null coerces to 0 for relational ops (>, <, >=, <=) but NOT for ==. This creates the famous null>=0 && !(null==0) quirk.

More Type Coercion Output Questions

EasyPlus operator: string concat vs numeric addMediumLoose equality edge cases with nullEasytypeof for common valuesMediumTruthy and falsy — empty array and object are truthy

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz