I expected !!"false" to return false i.e. !"false" would return true, so !!"false" would return "false", but when I tested it in the console, !!"false" returned true.
Why didn`t things happen as expected?
"false" is a non-empty string, which evaluates to true. Hence !"false" is false and !!"false" is true. You were probably thinking of !!false.
The reason this is occurring because anything other than an empty string will return true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With