Is there any reason to use !!someValue
(which is equivalent to Boolean(someValue)
) in a boolean context? In other words, in situations like if (someValue) ...
, does it make sense to write if (!!someValue) ...
?
It hurts my eyes and I think it's redundant, but I want to verify that there aren't any edge cases that require it - because I came across a codebase where this seems to be the default way of checking for truthiness.
Clarification: yes, in the general case !!someValue
will convert someValue
to a boolean; I'm referring to contexts where the runtime will automatically convert someValue
to true
or false
.