Convert string to boolean
suggest changeTo convert a string to boolean use
Boolean(myString)
or the shorter but less clear form
!!myString
The empty string is the only falsy string. Boolean("false") and Boolean("0") are both true.
Boolean('') === false // true
Boolean("") === false // true
Boolean('0') === false // false, because "0" is a non-empty string
Boolean('any_nonempty_string') === true // true
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents