Let us say you have the following string that contains Boolean value.
var test = 'true';
Here is a command to convert it into Boolean values.
var test_boolean = (test === 'true'); // returns true
In the above command, we basically check the value of test variable against string using === operator, which returns Boolean true in case of equality, else it returns Boolean false. Since we use identity operator (===) it does not do type conversion in case the variable is not a string.
Alternatively, you can also use equality operator to do the comparision.
var test_boolean = (test == 'true');
Similarly, if your string has a different case of string, you need to modify your expression accordingly. Here is an example if your variable is ‘TRUE’.
var test_boolean = (test === 'TRUE');
How to Convert Decimal to Hexadecimal in JS
How to Add 30 Minutes to JS Date Object
How to Measure Time Taken in JS Function
How to Replace Part of String in Update Query
How to View Live MySQL Queries