<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
Generate random password for form field on click using JavaScript
jQuery simple form validations between start date and end date
How to scroll page to particular Div on click using jQuery?
Get largest number from each sub-arrays
How to check a variable is undefined in JavaScript?
How to get selected text from a select box using jQuery?