MediumType Coercion💻 Output Question

Unary plus converts to number

💡

Hint

Unary + is the shortest coercion to number. undefined and non-numeric strings produce NaN.

What does this output?

console.log(+'');
console.log(+null);
console.log(+undefined);
console.log(+true);
console.log(+'3.14');

Correct Output

0
0
NaN
1
3.14

Why this output?

Explanation: +"" → 0. +null → 0. +undefined → NaN. +true → 1. +"3.14" → 3.14.

Key Insight: Unary + is the shortest coercion to number. undefined and non-numeric strings produce NaN.

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