Answers for "javascript cast to boolena"

2

javascript parse string to boolean

let bool = "True";
JSON.parse(bool.toLowerCase());
Posted by: Guest on July-26-2021
6

convert string true to boolean true javascript

stringToBoolean: function(string){
    switch(string.toLowerCase().trim()){
        case "true": case "yes": case "1": return true;
        case "false": case "no": case "0": case null: return false;
        default: return Boolean(string);
    }
}
Posted by: Guest on May-05-2020

Browse Popular Code Answers by Language