How to convert string to boolean | JavaScript

The Boolean object is an object wrapper for a boolean value. In order to convert a string to a boolean, use the strict equality operator to compare the string to the string "true". The "===" operator will not do the conversion, so if two values are not the same type === will simply return false.
let myString='true'; let myBool = (myString.toLowerCase() === 'true'); console.log(myBool); //returns true

If the condition is met, the strict equality operator will return the boolean value true, otherwise false is returned.

How can I convert a string to boolean in JavaScript

Using Comparison Operator

Also, do a one liner with a ternary if using comparison operator.
let myString = "true" let myBool = myString == "true" ? true : false console.log(myBool); //returns true

Using JSON.parse()

The JSON.parse( ) method parses a string, constructing the JavaScript value or object described by the string.
let myString='true'; let myBool = JSON.parse('True'.toLowerCase()); console.log(myBool); //returns true

Using Regular Expression

The test() method of JavaScript matches a regular expression against a string.
let myString = "true"; let myBool = (/true/i).test(myString) console.log(myBool); //returns true
The "/i" at the end of regular expression is for case insensitive match.