In JS, it's not clear if '0' is truthy or falsy. So, we have :
Boolean('0') == true, because it's a non-empty string.
But: ('0' == false)
The brain-itching starts from here :
(!'0' == false)
And then so...
('0' == !'0') // What ?!?
At the beginning, willing to store a websocket stream into a Mysql DB, I needed to convert each field from a string to its primitive type.
Using the double NOT operator to get booleans didn't produce the result I was expecting :
(!!"1" == true) && (!!"0" == true)
Having my input string s, I finally came up with this working solution :
!!+s
Or this one : (s == '1')