function isActive(status) {
if (status == false) {
console.log('inactive');
} else {
console.log('active: ' + status);
}
}
isActive(0);
isActive('');function isActive(status) {
if (status === false) {
console.log('inactive');
} else {
console.log('active: ' + status);
}
}
isActive(0);
isActive('');Bug: == coerces both sides. 0 == false and "" == false are both true because all three coerce to 0. Valid status values 0 and "" are incorrectly treated as inactive.
Explanation: With ===, only the boolean false is inactive. 0 and "" are valid statuses that pass through correctly.
Key Insight: Use === when distinguishing false from other falsy values like 0, "", and null.