WTFJS with Math (or why 0.1 + 0.2 results in 0.30000000000000004)

A few fun little Math-related wtfjs examples. A classic one is adding an empty Array and an empty Object: [] + {} // ‘[object Object]’ {} + [] // 0 If you’re looking for a hint: Coercion. JS WTF with Math →0.30000000000000004.com →

Can (a ==1 && a== 2 && a==3) ever evaluate to true?

Is it ever possible that (a ==1 && a== 2 && a==3) could evaluate to true, in JavaScript? This is interview question asked by a major tech company. My answer was that it’s impossible. They said nothing is impossible. It happened 2 weeks back, but I’m still trying to find the answer. I know we …

Down the Rabbit Hole: Javascript in Wonderland

Talk by Claudia Hernández, on a few of Javascript’s oddities and (un)expected behaviors: There’s a presentation embedded in this post. View it on Speaker Deck. For a language originally created in 10 days it surely has a lot of quirks and perks many JS developers are unaware of. Sometimes, it might even seem like we …