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

A social media community hosted in the UK; part of the Mastodon/ActivityPub federated social network, which allows you to follow users on other communities. It's a bit like Twitter but without a single company in control.

If you use this server, you are required to abide by our Code of Conduct. If you don't like it, there are plenty of other communities you can use.

If you're coming here from Twitter, there are some very useful services to help you find friends and automatically crosspost toots that you might like to set up once you're signed in.


This is a volunteer-run community administered by @floppy, and hosted by Mastohost in the UK. Please support our running costs by joining the Open Collective and becoming a backer. Thanks go to our existing backers - this place exists because of them!

Service status is available from our status page and the @status account.