Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  23] [ 4]  / answers: 1 / hits: 21978  / 14 Years ago, tue, january 4, 2011, 12:00:00

Possible Duplicate:

How can I convert a string to boolean in JavaScript?






Hi,



How can I cast a String in Bool ?



Example:
False to bool false



I need this for my JavaScript.



Thank you for help !


More From » javascript

 Answers
7
function castStrToBool(str){
if (str.toLowerCase()=='false'){
return false;
} else if (str.toLowerCase()=='true'){
return true;
} else {
return undefined;
}
}


...but I think Jon's answer is better!


[#94385] Sunday, January 2, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;