I am experiencing some of the weirdest behavior of Javascript.
Even though the expression in the if
statement evaluates to false
, my code inside the if block
keeps executing.
Here is the code snippet:
if (view.leftCols !== null) {
var leftCols = view.leftCols.split(',');
for (var lc = 0; lc < leftCols.length; lc++) {
var lcv = leftCols[lc].split(':');
var lcol = lcv[0];
Array.add(allCols, lcol);
try {
var lwidth = lcv[1] - MyWorkGrid.getColWidth(lcol);
if (lcol === 'Edit') {
if ($.browser.msie && parseInt($.browser.version) <= 8) {
lwidth = 23;
}
}
// this if statement fails.
if (lwidth > 0) {
grid.SetWidth(lcol, lwidth);
}
} catch (e) {
}
grid.MoveCol(lcol, 0, 1, 1);
}
}
Here is my Firebug screenshot:
Any ideas?
Despite the line being highlighted in Firebug, are you sure it's really being executed? I've seen this behavior in Firebug (and early versions of the Chrome debugger) where they would sometimes highlight a line of code as though they'd stepped to it, without that line actually getting executed.
So I'd insert something unambiguous (like a console.log("lwidth = " + lwidth);
into the if
statement's body to see if it really executes. The answer may be that Firebug is just highlighting/showing that line as the current one incorrectly without the code thereon actually being run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With