Avatar

Level 10

Hi,

there are 2 versions of the equal/not equal operators.

== and != are the lazy ones that don't compare the types of the values you're testing.

=== and !== are the strict ones, that also compare the type.

Here's a small example to demonstrate:


var a = 1, b = true;



if (a === b) {


  // Shown whenn == is used, because a is a number and b is interpreted as a number too


  // Here happens a implicit type conversion of the bolean value into a number


  xfa.host.messageBox("a is equal to b");


} else {


  // Shown when === is used, because a is a number and b is a boolean value


  // The values are not comparable


  xfa.host.messageBox("a not equal to b");


}


So your script may fail unexpected if when you use the strict versions without knowing the type of the values you compare.

Try this script.


var fSelected = this.rawValue,


     vRows = FeeDetailsTable._Row1.count-1;


     xfa.resolveNode("ChangeRequestForm.Table1.Row1.Cell1").rawValue = fSelected; //works



for (var i = vRows; i >= 0; i -= 1) {


  var vNode = FeeDetailsTable.resolveNode("Row1[" + i + "]");


    if (vNode.LicenseFeeDetailsId.rawValue != fSelected) {


    FeeDetailsTable._Row1.removeInstance(i);


    }


}