Javascript
Apr 26, 2026
What does this output?
console.log(null + 1)
console.log(undefined + 1)
Explanation
null converts to 0 when used in math, so null + 1 = 1. undefined converts to NaN (Not a Number), and any math with NaN gives NaN. This trips up a lot of developers — null and undefined behave very differently in arithmetic.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.