Is there a function or statement I can use to check for true/false that I could be getting from php, or html, or some source that would provide a true or false value that javascript would not understand as boolean. So I could check for the string true or boolean true or a 1 value (which php returns for true, I think..)
So like:
var trueVal = true;
if ( trueVal == true || trueVal === true || trueVal == "true" || trueVal == "TRUE" || trueVal == "1" || trueVal == 1 ) {
//
}
Does this make sense? Is there a much easier way to do this?
Thanks!
Well if you can make sure the
trueis passed correctly, then it could be a lot easier:The only time this would be a problem is if you had the string
"false"or"0", but that can be fixed: