I have a 开发者_StackOverflowJavaScript string containing "true"
or "false"
.
How may I convert it to boolean without using the eval
function?
var val = (string === "true");
You could simply have: var result = (str == "true")
.
If you're using the variable result:
result = result == "true";
精彩评论