πŸͺ TechCookies
HomeDSASystem DesignJSMy Progress
Free
Log inStart free
TechCookies β€” Practice Β· Learn Β· PrepareTechCookies β€” Practice Β· Learn Β· Prepare
ConceptsPracticeSD challengesPricingPrivacyTermsContact
Β© 2026 TechCookies
JSβ€ΊType Coercion & == vs ===
πŸ”€Type Coercion & == vs ===beginnerFreeJS
coercion=====truthyfalsy
Learn
0/10 done~73 min
1
The bug that ships to production
Problem
~3 min
πŸ”’
The Abstract Equality Algorithm
Mental
Complete previous first
πŸ”’
Five rules to write by
RulesQuiz
Complete previous first
πŸ”’
The 24 type coercion exceptions
Exceptions
Complete previous first
πŸ”’
Predict the output
Predict
Complete previous first
πŸ”’
True or false?
T/F
Complete previous first
πŸ”’
Fill in the blanks
Fill
Complete previous first
πŸ”’
Fix the bugs
Fix Bug
Complete previous first
πŸ”’
Spot the bug
Spot Bug
Complete previous first
πŸ”’
Cement your understanding
Cement
Complete previous first
1 / 10Read~3 min
The bug that ships to production
Spot the bug β€” then we'll break it down.
πŸ›Real bug β€” can you spot it?
1function isFieldEmpty(value) {
2 if (value == false) { // ← intended: check if value is "empty"← bug here
3 return true;
4 }
5 return false;
6}
7
8// User enters 0 as their age
9console.log(isFieldEmpty(0)); // true ← wrong: 0 is a valid age
10console.log(isFieldEmpty("")); // true ← correct
11console.log(isFieldEmpty(null)); // true ← correct
12
What goes wrong

The user enters 0 as their age. The condition value == false triggers the Abstract Equality algorithm: false converts to 0 (step 3), then 0 == 0 is true. A valid age is silently rejected. Ships to production.

In this concept you'll understand:
βœ“The exact 6-step algorithm == uses β€” never guess again
βœ“All 16 exceptions with the engine reason behind each
βœ“When == is safe and when to always use ===
βœ“How to convert types explicitly and predictably
Read through to continue
Notes
πŸ”
Loading…
Sections
0/10 done~73 min
1
The bug that ships to production
Problem
~3 min
πŸ”’
The Abstract Equality Algorithm
Mental
Complete previous first
πŸ”’
Five rules to write by
RulesQuiz
Complete previous first
πŸ”’
The 24 type coercion exceptions
Exceptions
Complete previous first
πŸ”’
Predict the output
Predict
Complete previous first
πŸ”’
True or false?
T/F
Complete previous first
πŸ”’
Fill in the blanks
Fill
Complete previous first
πŸ”’
Fix the bugs
Fix Bug
Complete previous first
πŸ”’
Spot the bug
Spot Bug
Complete previous first
πŸ”’
Cement your understanding
Cement
Complete previous first
Notes
Notes
πŸ”
Loading…