MediumType Coercion💻 Output Question

String comparison is lexicographic

💡

Hint

Number vs string uses numeric comparison. String vs string uses char codes (lexicographic).

What does this output?

console.log('5' > 3);
console.log('5' > '30');
console.log('10' > '9');

Correct Output

true
true
false

Why this output?

Explanation: "5">3: coerces to numbers, 5>3=true. "5">"30": string compare, "5" char > "3" char=true. "10">"9": "1"<"9"=false.

Key Insight: Number vs string uses numeric comparison. String vs string uses char codes (lexicographic).

More Type Coercion Output Questions

EasyPlus operator: string concat vs numeric addMediumLoose equality edge cases with nullEasytypeof for common valuesMediumTruthy and falsy — empty array and object are truthy

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz