<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 set checkbox and radio option checked on load with jQuery?
jQuery move multi select values from one to another multi select list
How to check a variable is undefined in JavaScript?
How to build simple tabs with jQuery?
How to check if an element or HTML tag exists using JavaScript?
ES6 method of declaration multiple variables in one line