Sitemap
JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.

The Quirky World of JavaScript: Exploring Its Funniest and Strangest Quirks 🤯🚀

4 min readMar 22, 2025

--

JavaScript is like that one eccentric friend who always manages to surprise you. Just when you think you’ve got it all figured out, BOOM! Another unexpected behavior pops up, leaving you scratching your head. 🤔 Whether you’re a seasoned developer or just starting out, JavaScript’s quirks make coding an exciting (and sometimes frustrating) journey.

So, let’s dive into some of the weirdest, most fascinating quirks of JavaScript and why they happen! 🕵️‍♂️💻

🎭 The Empty Array + Empty Array Mystery

Ever tried this in your browser’s console?

console.log([] + []);

You’d expect an empty array, right? But nope! JavaScript surprises you with an empty string ("").

🤯 Why Does This Happen?

The + operator in JavaScript is both an arithmetic addition operator and a string concatenation operator. When used with arrays, JavaScript first converts them to strings using .toString().

Since [].toString() returns an empty string (""), adding two empty arrays together results in:

"" + "" // → ""

💡 Takeaway: Always be mindful of implicit type conversions in JavaScript!

🧐 null is an Object? Wait, What?!

console.log(typeof null); // "object"

--

--

Umadevi R
Umadevi R

Written by Umadevi R

Software Developer at PayPal | EX-Amazon | Sharing insights on coding, interview preparation, software architecture, and emerging tech trends. 🚀 #FAANG

JavaScript in Plain English
JavaScript in Plain English

Published in JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.