A logical NOT operator !
converts a value to a boolean that is the opposite of its logical value.
The second !
converts the previous boolean result back to the boolean representation of its original logical value.
From these docs for the Logical NOT operator:
Returns false if its single operand can be converted to true; otherwise, returns true.
So if getContext
gives you a “falsey” value, the !!
will make it return the boolean value false
. Otherwise it will return true
.
The “falsey” values are:
false
NaN
undefined
null
""
(empty string)0