Skip to content

Comment on Wat

Comments

I guess you had to be there. I can see why someone might find this funny, but honestly, nothing is that funny. Some behavior in Javascript is surprising, but not that surprising.

If you've ever gone through a phase (or a graduate degree!) of thinking deeply about programming language design, you might, as I do, find Javascript's expression evaluation behavior to be just about the funniest thing around.

I have but I don't. Javascript was designed to reduce programmer-visible errors at the cost of making it nearly impossible to write a correct program. At that goal, it succeeds, and [] + {} being NaN makes perfect sense under those constraints.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.