Discussion

In JavaScript, why does (null + null === 0) return true?

I could be convinced into thinking == would return true if null was treated as 0 (so 0 + 0 = 0), but with ===, this doesn't seem right at all, especially considering:

typeof null === 'object'

and

typeof 0 === 'number'

Can someone explain?

1 points swozniak 12 years ago 4 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton