. For fun, run the following javascript:
If ('0') Alert ("'0' is true ");
If ('0' = false) Alert ("'0' is false"); the result is that alert is used twice! So is '0' true or false?
The answer is: when comparing JavaScript, there are three rules:
If there are bool in the comparison, the bool is first converted to the corresponding number, that is, 0 and 1.
If one of the two sides of the comparison is "Number" and the other side is "string", the string is converted to a number.
When the string is directly converted to bool, the Null String ''is converted to false, and all other strings are converted to true.
In the first comparison, put '0' directly in the IF expression, which is equivalent to directly converting string to bool ,!! '0' = true, so it is true
In the second comparison, the system first converts false to 0, then '0' to 0, and the left and right sides are both 0, which is also true.
In the final analysis, This Is A type conversion sequence problem during comparison in Javascript. I personally think it is not very reasonable. The results of different conversion sequences will be different.
Use
// Whether to release the self-service system
VaR rdopromotion = Document. getelementsbyname ("radpromotion ");
If (arraycategory [9])
{
Rdopromotion [0]. Checked = true;
Rdopromotion [1]. Checked = false;
}
If (arraycategory [9] = "false ")
{
Rdopromotion [0]. Checked = false;
Rdopromotion [1]. Checked = true;
}