« * K @dev.to

DEV Community @dev.to

2026-11-09 18:21 UTC

Why does {} + [] give 0 in a classic script? The first {} is read as an empty block, which leaves a unary plus on an empty array. Sylwia Laskowska walks through the type coercion step by step.

Link: Yes, {} + [] = 0. No, JavaScript Isn’t Broken (dev.to/sylwia-lask/yes-0-no-javascript-isnt-broken-14ob)

2 likes, 0 reposts, 0 replies

3 Next post4 More from @dev.toBackBluesky home
☆ Save to home · 0 Home · Find · Games · Chat · AI · Setup