JSFiddle - React, Tailwind, and code Playground

JavaScript

function getBool(val){ 
    var num = +val;
    return !isNaN(num) ? !!num : !!String(val).toLowerCase().replace(!!0,'');
}

function test(val){
    console.log(val, getBool(val));
}

test(false);
test(true);
test(0);
test(1);
test("0");
test("1");
test("false");
test("true");
test("FALSE");
test("TRUE");
test(undefind);