Predict Type Coercion
Predict Output Medium
Question
What does this code print?
Code
console.log(0 == false);
console.log(0 === false);
console.log("" == 0);
console.log(null == undefined);
Hint
== coerces types; === does not.
Explanation
0 == false is true (false coerces to 0). 0 === false is false (different types: number vs boolean). "" == 0 is true (empty string coerces to 0). null == undefined is true (special rule: null and undefined are loosely equal to each other only).
Related Resources
Related Lessons
- JavaScript Data Types
Learn about type coercion rules.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.