I'm trying to understand what exactly the double exclamation mark does. Yes, I saw this question, with lots of answers. So I know in principle what it does, but I don't know why one would ever need to use it.
From what I understand, it converts the value to a boolean. So let's say I have the following code:
var myBool = !!(index === 0 || index > len);
Can't I just leave out the !!
and I will get the same result:
var myBool = (index === 0 || index > len);
What do I gain by adding !!
? Is't it already a boolean vaule?