<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
jQuery move multi select values from one to another multi select list
JavaScript HTML5 Validation for name and email field
How to check a variable is undefined in JavaScript?
How to join string with number in JavaScript?
How to scroll page to particular Div on click using jQuery?
JavaScript simple alert on Click