C
Carlos Aguayo
Hi,
Is there a better way to do this?
The problem that I have is that x can be "true" or "false" (as type
string), or true or false (as boolean type). I'm doing comparisons
like...
if (eval(x) == true){
// do something...
}
or..
if (eval(x) == false){
// do something...
}
I'd like to get rid of the eval, I tried to use the !!, but if I do !!x
when x is "false", it returns true since it's not an empty string. Do
you know a better way to do this? Without forcing x to be always a
string or always a boolean?
Thanks,
Carlos
Is there a better way to do this?
The problem that I have is that x can be "true" or "false" (as type
string), or true or false (as boolean type). I'm doing comparisons
like...
if (eval(x) == true){
// do something...
}
or..
if (eval(x) == false){
// do something...
}
I'd like to get rid of the eval, I tried to use the !!, but if I do !!x
when x is "false", it returns true since it's not an empty string. Do
you know a better way to do this? Without forcing x to be always a
string or always a boolean?
Thanks,
Carlos