Type Coercion with Boolean
Multiple Choice Medium
Question
What does Number(true) + Number(false) return?
Hint
true becomes 1, false becomes 0.
Explanation
Number(true) is 1 and Number(false) is 0, so the sum is 1. When booleans are coerced to numbers, true maps to 1 and false maps to 0. This is why you can use bitwise tricks, though they are rarely needed in modern JavaScript. Be careful with implicit coercion in arithmetic.
Related Resources
Related Lessons
- Data Types
Learn about primitive data types.
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.