# double negation !!
Double negation in JavaScript what is the purpose : stackoverflow.com
It casts to boolean. The first ! negates it once, converting values like so:
undefinedtotruenulltotrue+0totrue-0totrue''totrueNaNtotruefalsetotrue- All other expressions to
false
Then the other ! negates it again. A concise cast to boolean, exactly equivalent to ToBoolean simply because ! is defined as its negation. It’s unnecessary here, though, because it’s only used as the condition of the conditional operator, which will determine truthiness in the same way.