🟒 EasyType CoercionπŸ’» Output Question

Loose equality coercion

πŸ’‘

Hint

null only loosely equals null and undefined β€” nothing else. This trips everyone up.

What does this output?

console.log(0 == false);
console.log(1 == true);
console.log('' == false);
console.log(null == undefined);
console.log(null == false);

Correct Output

true
true
true
true
false

Why this output?

Explanation: 0==false: both coerce to 0. 1==true: both coerce to 1. ""==false: both coerce to 0. null==undefined: special case in spec. null==false: null only equals null/undefined, not false.

Key Insight: null only loosely equals null and undefined β€” nothing else. This trips everyone up.

More Type Coercion Output Questions

🟑 MediumAddition vs concatenationβ†’πŸŸ‘ MediumFalsy values comparisonβ†’πŸŸ‘ MediumNaN comparisonβ†’πŸ”΄ HardObject to primitive coercionβ†’

Practice predicting output live β†’

66 output questions with instant feedback

πŸ’» Try Output Quiz