GUIDE深度 · Deep 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.
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.