by esrauch · 14y ago · 0 comments
var a = {} + [];
var b = [] + {};
var c = String({}) + String([])
All three are equal. The order does matter in general because its doing string concatenation which obviously matters ([1] + [2] == "12"), but the fact that js always does string coercion and concatenation anytime you have + without numbers on both side isn't really that crazy.
There are plenty of parts of JavaScript like that, but these gotchas are just red herrings. The core language is great.