```javascript
const f = new Boolean(false); console.log(f == !f); // Outputs `true`
```

@neonpaul coecion! new Boolean creates an object wrapper, not a boolean value. so that’s describing {} == !{} which the dbl equals coerces to Number leading to 0 == !0 which is true.

@neonpaul the only real funkiness imho is that JS is designed to coerce an empty object to 0 instead of NaN.

@pixelpaperyarn well I think `==` coerces instances of Boolean to their equivalent boolean value, whereas `!` doesn't, it just sees a truthy object, so inverts it to `false`. Not that I'm complaining, i just find it interesting some of the weird pointless stuff you can do.

@neonpaul oh you’re right! and yes these weird little things are indeed interesting.

Sign in to participate in the conversation
Open social media for the UK

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!