Long time software architect, CTO Authress, creating application security plug-ins for any software application with Authress. Talk to me about security in microservices or service authorization.
I feel like they article made this whole concept really complicated. It's actually simple, What is !!?. It's the same as Coerce to boolean. It would do the same as a method Convert.toBoolean(value) where value is truthy or falsy and the result is true or false.
You need this because some parameters are expected to be true or false and not truthy and falsy. Boolean(value) doesn't actually coerce a value to a boolean, it's unfortunately less useful than that. And so using !! (the double NOT) is a great way to coerce a value to a boolean.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I feel like they article made this whole concept really complicated. It's actually simple, What is
!!
?. It's the same asCoerce to boolean
. It would do the same as a methodConvert.toBoolean(value)
where value istruthy
orfalsy
and the result istrue
orfalse
.You need this because some parameters are expected to be
true
orfalse
and nottruthy
andfalsy
.Boolean(value)
doesn't actually coerce a value to a boolean, it's unfortunately less useful than that. And so using!!
(the double NOT) is a great way to coerce a value to a boolean.