Copy link to clipboard
Copied
In this snitppet the if is entered - but I do not understand why:
$.writeln (oFound + " " + KLD_F.iError);
if (oFound == undefined || (KLD_F.iError != 0)) { // Nothing found -----------
KLD_F.DisplayInfoF (KLD_F.UItxt.ButtonFind.@msg_07.toString(), "red"); // not found (anymore)
KLD_F.bNextCompOK = true; // propably look into next book component
}
The writeln says: null 0
Is in the condition null the same as undefined?
HM, have found this in StackOverflow:
null === undefined // false
null == undefined // true
That means that my test is incorrect and I need to write it differently, probably:
if (oFound === undefined || (KLD_F.iError != 0)) {
But: In the script I often force this condition "not found" by setting the variable oFound to undefined ... Will ths still work?
Yes, this is the correct solution.
Edit
I have found an excellent explanation of the null vs undefined problem at StackOverflow. Look for
...Copy link to clipboard
Copied
HM, have found this in StackOverflow:
null === undefined // false
null == undefined // true
That means that my test is incorrect and I need to write it differently, probably:
if (oFound === undefined || (KLD_F.iError != 0)) {
But: In the script I often force this condition "not found" by setting the variable oFound to undefined ... Will ths still work?
Yes, this is the correct solution.
Edit
I have found an excellent explanation of the null vs undefined problem at StackOverflow. Look for "Please read the following carefully".