4 ms·
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 prob
by Karunamon 12y 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)
- rdtsc 12y agoBecause it hides errors instead of helping the developer find them
- Karunamon 12y agoAre 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)
- tokenizerrr 12y agoNo. You generally only add numbers and strings together.
- rdtsc 12y agoAs 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.
- gtirloni 12y agoExtreme nonsense behavior from the language you're using. People see that and think "that's just the tip of the iceberg".
- marcosdumay 12y agoIt 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...