Where this matters
Form input often arrives as a string. Decide whether to convert it before comparing it with a numeric value.
console.log(0 === '0');
console.log(0 == '0');Read the full explanation
Strict equality does not coerce the different types. Loose equality converts this number/string pair before comparing.
Trace the code
- The first comparison has a number on the left and a string on the right. Strict equality rejects this type mismatch.
- The second comparison applies the loose-equality rules, which convert this string to a number.
- These results describe this particular pair; loose equality is not a general-purpose text parser.
Why the other predictions differ
true true— Strict equality distinguishes the number from the string.false false— Loose equality converts string zero to numeric zero here.
false true
Reading this explanation does not record mastery. A correct submitted attempt can do so, including after review.
Change one thing
Convert the string deliberately, then compare two numbers with strict equality.
Predict the result, then run this self-contained snippet in your browser’s developer console. It uses only sample values and makes no network requests.
console.log(0 === Number('0'));Check the variation’s output
true
Explain which binding, value, or operation changed before moving to the next challenge.