Hacker News new | ask | show | jobs
by Karunamon 4367 days ago
I assume you're referring to the "Wat" talk by Gary Bernhardt, here.

My question is why does it matter? It's funny and notable behavior, but why is this a problem that a real programmer will face dealing with a real problem?

(For reference, [] + [] = "", [] + {} = Object, {} + [] = 0, {} + {} = NaN)

3 comments

It matters because it shows how incoherent is the Javascript type system, and how easy it is to get biten by it.

About Python lambdas, I miss them a lot. But one can not have everything...

Because it hides errors instead of helping the developer find them
Are JS developers often adding empty arrays and empty objects together? This seems more like a corner case than a real issue.

(Not snarky - I don't know JS)

As often as any programmers deliberately insert bugs in their code ;-)

Those values are usually in variables that and have been set maybe from a backend reply or from the UI at some point.

That is just one instance of the sloppy mess of weak typing. Instead of writing a long list of it I just used an example to illustrate.

No. You generally only add numbers and strings together.
Extreme nonsense behavior from the language you're using. People see that and think "that's just the tip of the iceberg".