<script>
var str = "true";
var bool = strToBool(str);
function strToBool(s){
regex=/^\s*(true|1|on)\s*$/i
return regex.test(s);
}
console.log(typeof str); // String
console.log(typeof bool); // Boolean
</script>
Most Helpful This Week
How to scroll page to 1000px from top on page load using jQuery?
JavaScript check if first string contains all characters of second string
jQuery simple form with name and email validations
Get largest number from each sub-arrays
Generate random password for form field on click using JavaScript
How to change text after click event using JavaScript?