Using !!someVariable
might seem smart to turn a value into a boolean in JavaScript, but is it intuitive for someone who doesn’t know this JavaScript "trick" to understand?
Try using Boolean(someVariable)
to make your intentions easier for everyone to understand. Write JavaScript for humans 🙌
I’ve created a test script which confirms that Boolean()
and !!
behave the same way: https://gist.github.com/simonplend/be1f26a83a1b0769bd374e14d244aa07