GUIDEDeep dive

How to Read JavaScript Output

For JS output, check types first: + concatenates with strings, while - coerces to number. Then truthiness: 0, '', null, undefined and NaN are falsy. Write answers as JSON with double-quoted strings.

Updated 2026-11-01 · Formula checked

Coercion

"5" + 2 = "52"; "5" - 2 = 3.

[] + [] = ""; [] + {} = "[object Object]".

Truthiness

0/''/null/undefined/NaN are false.

?? handles only null/undefined; || handles all falsy values.

FAQ

Why are answers quoted?

JSON strings need double quotes to distinguish them from numbers.

How is undefined shown?

As undefined, not a string.

Sources

Related calculators

JavaScript Output: 1000 Gamified Expression and Array Cards1000 JavaScript output cards covering arithmetic, strings, array methods, objects, JSON and logic, in 50 levels with spaced repetition.

More guides

Hiragana vs KatakanaRead guideSpaced Repetition and the Forgetting CurveRead guideOn Readings vs Kun ReadingsRead guideAn N5 Kanji Study OrderRead guide
KEEP READING

Keep reading

Read in order, or jump to another guide on the same topic.

All guides →

None