JavaScript is a legendary programming language. Created in the mid-1990s in just 10 days, it was born during the browser wars, when Netscape was tr...
For further actions, you may consider blocking this person and/or reporting abuse
Ok, see you folks! 😆

My aviation nerd eyes instantly spotted the Lufthansa logo 😄
Nice article by the way!🔥
Thank you so much! Hahaha, Giorgi, you're right, the logo is actually there! You've got a good eye! Although I have to say, I feel like Lufthansa has gone a bit downhill lately, and these days I actually prefer Polish LOT! 😄
Yeah, I've noticed that too. It's closer to a budget airline than a luxury one.
I haven't flown with LOT Polish Airlines though.
Hahaha, on LOT you even get a sweet bun! And seriously, it's actually pretty good! I think they bake them fresh regularly. You can also get beer or wine in a plastic cup. 😅 Although on some flights they seem to keep that a secret, and you have to know to ask for it! 😂 I usually go for the wine, but there's always that fear that one unexpected bout of turbulence will leave me completely covered in it. XDDD
You folks are on fire! A great country with an airline THAT good... Poland is really out there going for being the best country in Europe. And it's working. 😄
This is the most JavaScript thing I've seen, and I am not disappointed XD
Hahaha, Francis, this is just the tip of the iceberg when it comes to JavaScript weirdness!
That’s weird. I never get notifications for your posts. I only found this fantastic article more than ten hours late. Must be a bug on Dev.to!😂😍
Hahaha, who knows, maybe it's all part of some conspiracy! 😂
JavaScript is one of those languages where you can explain exactly why something happens, walk through every step of the specification, demonstrate that the implementation is behaving correctly, and still conclude that the language has made some questionable life choices.
The distinction between
{} + []and({} + [])is particularly entertaining. Same characters, different parsing context, entirely different result.Glad to see the series back! If this is what two hours at Frankfurt Airport produces, perhaps longer layovers should be encouraged.
Hahaha, exactly! Everything makes sense, everything has a perfectly logical explanation, and yet it never stops being funny, even after all these years!
And as for airports, I actually quite enjoy writing there! It's only when I'm at an airport that I realize just how much time writing articles really takes. Somehow, when I'm at home, I don't notice it nearly as much. 😂
Hi Sylwia! JS is my favorite programming language, as you know, since Adobe killed Flash. But honestly, JS is better because it’s free to use. Maybe you could try TDM = Travel Development Method, which is also a vibe coding aberration. It means nothing more than programming while travelling. By the way, I’m happy to have found a similar concept in UMGD.
But let’s get back to JS. I’m a really big fan of it, which is why I argue for JSDoc instead of TS. These positive feelings also led me to create mordorjs, which, at the end of the day, is pure JS. It just uses a strange ability of JS that lets you write working code in a one-character-wide format.
Hahaha, Peter, yes, I know how much you love JavaScript! I personally use TypeScript, but I totally get your point!
Actually, just the day before yesterday, I was chatting with some fellow developers in Munich, and we started reminiscing about the old days when TypeScript was just emerging. I remember we were a bit hesitant to adopt it because, well, what if Microsoft decided to abandon the project?
But what eventually convinced us was that TypeScript compiled down to pretty clean, readable JavaScript. That was our main argument: we could always go back to that slightly crazy but beautiful language!
Right now thanks to open script behiaviour of TypeScript any one can fork it, and make it own verison with own solution, so right now TS is bit versatile compared to JS, there is need to wait a new upgradding in every years.
Imagine explaining this in a code review: "No, the empty block isn't useless. It's what gets us zero 😂" Also love that adding just one pair of parentheses makes JavaScript treat
{}as an object. Can't wait for the{} + {}one, Sylwia!Hahaha, I doubt it would even make it to code review! More likely, someone would be sitting there wondering, "Why the hell isn't this code working?!" 😂
JavaScript has so many deep parts or maybe shallow parts? 😹
I always find it funny how something as simple as an empty object and an empty array can behave so differently depending on how the parser sees them.
These little quirks are one of the reasons JavaScript keeps surprising us. 🐟
As always, your article was really easy and fun to read!
Have a safe trip home! ✈️😸
Aww, thank you! ❤️ I'm already back home! :) And exactly! This kind of knowledge probably won't be very useful in our everyday coding. Although I remember there was (and I think there still is) a website called Return True to Win, where knowing these weird JavaScript tricks actually came in handy!
I remember joking with my colleagues at work that one day we'd give someone those challenges during a job interview. And then, a few years later, someone actually gave me one of those challenges in an interview! 😂
Haha, that’s amazing 😹
The fact that a joke challenge came back as a real interview question years later is peak JavaScript. 😹
And glad you made it home safely! 😸
One thing worth remembering is that JavaScript's object semantics can become a production security issue, not just a source of funny console output.
There's a good example in
qs(CVE-2026-82417). An attacker could influence an object's shape through query parameters, and laterqs.stringify()would try to invokeconstructor.isBufferwithout checking whether it was actually callable. That could trigger aTypeErrorand cause a DoS.It's a different edge of JavaScript than
{} + [], but the underlying lesson is similar: what looks like a perfectly ordinary object isn't necessarily what the next operation expects.That's why I think understanding these language rules matters beyond passing a JavaScript interview.
Oh, I didn't know about this one! But that's exactly the thing with JavaScript. It's not always just about funny console tricks. Sometimes making assumptions about objects can have some really serious consequences!
There's another interesting edge case with coercion:
Symbol.toPrimitive. It's not just about how an object gets converted to a string or number. An object can actually control what happens during that conversion.I've seen this become particularly relevant with custom value objects in financial systems. Imagine a
Moneyobject used in a calculation, but its primitive conversion returns a formatted string for display. Suddenly, an expression liketotal + amountcan switch from numeric addition to string concatenation, depending on which object is involved.That's one reason I prefer explicit methods like
money.add(other)andmoney.toMinorUnits()over relying on implicit conversion. The language is doing exactly what the spec says, but the business logic might be doing something completely different from what the developer intended.I dislike people who make fun of JS as a coding language by point out its weird parts. JavaScript was originally designed to be a lightweight scripting language that allowed non-programmers to add interactivity to web pages. Over time, it evolved far beyond that original purpose and now powers everything from frontend applications and backend services to mobile apps and desktop software.
I think it's unfair to judge a language solely by its weirdest edge cases, especially when you consider how much its scope has expanded over the years. If you take almost any language and stretch it to support such a wide variety of use cases, you're bound to accumulate some quirks along the way. Just look at Python!
On a related note, I absolutely love this podcast episode about the origins of JavaScript. It's a fascinating listen and provides some great historical context for why the language is the way it is.
The Origins of JavaScript
But that's exactly what I wrote about in the article! How JavaScript came to be, how much it has evolved over the years, and why it still has to preserve all those quirks for the sake of backward compatibility.
And besides, think about how much I must love this language if I'm willing to dig into its weirdest corners and explain exactly why they work the way they do!
Making fun of JavaScript's quirks doesn't mean I don't appreciate it. Quite the opposite! ❤️
JS being JS
How not to love it 😅
Great explanation! JavaScript's type coercion can be confusing, especially for beginners, but examples like these make the underlying rules much easier to understand. I also appreciate the distinction between {} as an empty block and an object literal. Definitely a fun reminder to pay attention to context when writing JavaScript!
Oh, absolutely! 😄 These days, most of us use TypeScript, and it sometimes feels like we're pretty well protected against JavaScript's weirdness in everyday development. But you never know, over the years, you end up working on all kinds of projects!
The sneaky part is +[] detouring through "" on its way to 0, same reason an empty form field sails past a Number() check
Exactly! 😂 JavaScript has been turning empty things into zero for 30 years, and we're still finding new ways to get surprised by it.
Thanks, Sylwia. That empty to zero path keeps showing up in the places you least expect it.
This is why I always write everything explicitly 😅 It's not a problem as long as we avoid it right?
Exactly! That's one thing! 😅 I also use TypeScript and linters to keep me (or my coding agent) in check whenever we get a little careless. Do you use TypeScript too?
I only use TypeScript (I literally forgot JavaScript lol), and I'd never do something like
{} + [](too risky 😬😅)Wow! The fact that
{}isn't an object at all, and that the+is unary - I didn't see that one coming! Might be logical "when explained after the fact", but I'm finding this truly bizarre ...Exactly! 😂 Just because you understand the logic behind it doesn't make it any less bizarre! I mean... well, it's JavaScript. XDDD
This is the longest "it's not a bug, it's a feature" I've ever read.