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.

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.
Related Topics
- JavaScript Popup Boxes
- Opening a new window in JavaScript
- How to Create Drop-Down Lists in JavaScript
- How do I include a JavaScript file in another JavaScript file?
- Print the content of a Div using JavaScript/jQuery
- How to get the current URL using JavaScript ?
- How to Detect a Mobile Device with JavaScript/jQuery
- How to validate an email address in JavaScript
- JavaScript Array Iteration
- How to Remove a Specific Item from an Array in JavaScript
- What is JavaScript closures?
- How To Remove a Property from a JavaScript Object
- How to get selected value from Dropdown list in JavaScript
- How do I get the current date in JavaScript?
- How to Open URL in New Tab | JavaScript
- How to delay/wait/Sleep in code execution | JavaScript
- How to round to at most 2 decimal places | JavaScript
- How to check undefined in JavaScript?
- How To Copy to Clipboard | JavaScript
- How to encode a URL using JavaScript?
- How to force Input field to enter numbers only | JavaScript
- How to create multiline string in JavaScript
- How to Check for an Empty String in JavaScript?