Otherwise strange things happen if the application adds properties to the Array prototype, another solution is to insert an "hasOwnProperty" check inside the "for in" loop, but the former is a better fix for arrays imho.
For example, in the loop function, starting from row 342:
for(var i in lengthsubjects){
var subj = lengthsubjects[i];
var difference = getObjDiff(subj.obj[subj.prop], subj.actual);
// ...
};
In this case, the loop will iterate also over non owned-properties, i.e. property added to the Array prototype.
So the code should be changed to:
for(var i=0,l=lengthsubjects.length; i<l; i++) {
var subj = lengthsubjects[i];
var difference = getObjDiff(subj.obj[subj.prop], subj.actual);
// ...
};
Same apply when iterating over objects, but in this case an "obj.hasOwnProperty(prop)" check inside the "for in" loop is required.
Otherwise strange things happen if the application adds properties to the Array prototype, another solution is to insert an "hasOwnProperty" check inside the "for in" loop, but the former is a better fix for arrays imho.
For example, in the loop function, starting from row 342:
In this case, the loop will iterate also over non owned-properties, i.e. property added to the Array prototype.
So the code should be changed to:
Same apply when iterating over objects, but in this case an "obj.hasOwnProperty(prop)" check inside the "for in" loop is required.