JavaScript is the kind of language that lets you build billion-dollar apps
and also lets this happen:
JAVASCRIPT1// What even is this? 2[] + [] // "" 3[] + {} // "[object Object]" 4{} + [] // 0 (wait, what?) 5{} + {} // "[object Object][object Object]" 6 7// This one's my favorite 8true + true + true === 3 // true 9 10// Type coercion going absolutely feral 11"5" - 1 // 4 12"5" + 1 // "51" 13"five" * 2 // NaN 14null + 1 // 1 15undefined + 1 // NaN 16 17// Oh, and this 18NaN === NaN // false 🤯
JavaScript lets [] == false
return true
typeof NaN is "number"
— makes total sense
coercion is not a quirk, it’s a philosophy
Boolean([])
is true but [] == false
is also true
console.log("hi"}
is your new best friend
😵 Final Words: JavaScript is not just a language — it’s a multiverse of madness with a runtime.
Use it responsibly. Or don’t. It’ll still run 😂
Updated