The first one he talks about is that [] + [] gives you "" (an empty string). I don't know what universe that makes sense in. [] + {} gives you {} back. Meanwhile {} + [] gives you 0. Yes, the order in which you add types that can't logically be added ends up giving you different incoherent answers. {} + {} gives you NaN.
One of the other sibling comments said that it was mostly implicit conversions, which I think is the underlying cause of most of these.
That's not to totally hate on Javascript, but the language could probably use fewer implicit conversions and more type errors. I struggle to think of a situation in which those outcomes are desirable, and it can cause extremely hard to follow stack traces. A JSON API returns a list of objects instead of a list of strings and now your types are screwed up in hard-to-follow ways.
{ }; +{}
If you put parentheses around it, or assign it to a value and then print that value then {}+{} isn't empty string.
Also see this minitalk (which actually gets some things wrong because of confusion on how the terminal interpreter behaves but is still amusing): https://www.destroyallsoftware.com/talks/wat
> [] == []
false
> [] == ![]
true This condition will always return 'false' since the types 'never[]' and 'boolean' have no overlap.
...for `[] == ![]`. Which is ironic because it does return true, not false. However at least it flags an error!I wonder how much of weirdness is wiped out by linters/ts/etc.