I have a Javascript String containing true or false.
How may I convert it to boolean without using the eval function?
Thanks
I have a Javascript String containing true or false.
How may I convert it to boolean without using the eval function?
Thanks
The most obvious:
if(string =="true"){ string = true; }else{ string = false; }
Or using ternary operator:
string = (string=="true") ? true : false;
Homework? Steam-driven method:
if (myString == false) myBoolean = false else myBoolean = true