5 ms·
Yeah, Gary was actually wrong about that one, you can actually hear objections from the audience: 1. [] + {} is actually the string '[object Object]' not an ob
by runarberg 4y ago
Yeah, Gary was actually wrong about that one, you can actually hear objections from the audience:
1. [] + {} is actually the string '[object Object]' not an object per say, {} is the object and [] + casts it to string.
2. {} + [] depends on runtimes. In firefox the first {} is actually an empty statement, not an object Object.fromEntries([]) + [] is always the string "[Object object]" just like [] + {}. In node you can do this {} {} + [] or even {1 + 1} + [] for the desired 0. Effectively it is the same as +[]
3. {} + {} is the same. The first {} is an empty statement
- kaba0 4y agoSee sibling comment