Convert string to boolean

suggest change

To 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents