Answers for "parse boolean js"

2

javascript parse string to boolean

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

js string to boolean

// Do
var isTrueSet = (myValue == 'true');
// Or
var isTrueSet = (myValue === 'true');
Posted by: Guest on April-02-2020
-1

js parse bool

function parseBool(value) {
    if (typeof value === "string") {
        value = value.toLowerCase();
        if (value === "true" || value === "false") {
            return value === "true";
        }
    }
    return; // returns undefined
}
Posted by: Guest on September-24-2021

Browse Popular Code Answers by Language