MediumType Coercion💻 Output Question

parseInt stops at first invalid character

💡

Hint

parseInt stops at the first non-parseable character. Always specify the radix to avoid ambiguity.

What does this output?

console.log(parseInt('10px'));
console.log(parseInt('0x1F'));
console.log(parseInt('10', 2));
console.log(parseInt('hello'));

Correct Output

10
31
2
NaN

Why this output?

Explanation: "10px"→10 (stops at p). "0x1F" is hex=31. Base 2: "10"=2. "hello"→NaN (no valid digits).

Key Insight: parseInt stops at the first non-parseable character. Always specify the radix to avoid ambiguity.

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