Note: it's actually a duplicate of What is the difference between if(!!condition) and if(condition)
While I understand what the !! means (double not), for this same reason it doesn't make sense to me its use in the MDN documentation:
if (!!window.Worker) {
...
}
Isn't this exactly the same as this for this situation?
if (window.Worker) {
...
}
The casting to boolean makes no sense for me since the if
will only be executed if the window.Worker
exists. To say that it's True
or Object
for an if()
conditional (I think) is the same.
So, why is the !!
used here? Or, why is the window.Worker
casted to boolean inside an if()
?