Originally, I thought that the boolean type conversion of js is the same as that of java. After all, everyone is the same ancestor. below is my writing method.
Function foo (){
Var temp = Boolean. valueOf ('<% = javatelean %> ');
Alert (temp = false );
}
The java variable javatelean is a string with the value "false". I thought it would be true, but the result would be false, which is really depressing.
Just now I checked the javascript authoritative guide, just now I was confused. It turns out to be like this:
If you want to convert other types to Boolean type, you should use Boolean (value), new Boolean (value), Boolean. the valueOf () method is only available to objects and is not a Boolean static method. It is also important that values 0, NaN, null, null, and undefined are converted to false, other original values, except false (but including the string "false"), and other objects and arrays are converted to true.
Here, you should think it's a value to be fooled by js?