1) whatever halfwit decided to call logical not a "bang" needs a bang upside the head with a baseball bat.

2) It's not a flipping operator, It's TWO of the same operator in a row.

3) Which is why you omitted one of the most useful aspects of logical not on truthy/falsy.

!falsy === true

Hence when you !!falsy of course it's false. You omitted the entire part of the operation that actually makes it worse.

You are basically saying "not not", it's the first one to execute (the second one in code order) that does all the magic forcing the value based on truthiness to boolean. The leading exclamation point simply flips it.

All this nonsense about calling it an operator seems to be leading people to treat it as the "only" operator, I've seen so many codebases now where people !!something in an if/else or ternary, where they could simply have !something and reversed the result order.

See your "nothing" example for that in action. I realize that's just a sample of !!, but nubes and rubes alike will blindly copy that as if it were how code should be written.

This is simple logic and sure as shine-ola doesn't warrant a goofball catchy name.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store