error handling - javascript override undefined -
after searching many hours dont find solution problem:
function pseudoclass(value){ this.value = value; } aplayground = new array(); aplayground[0] = new pseudoclass(0); var actual = 0; var width = 1; var bbool = new boolean(actual%width); //left becomes 0%1 ----> false if (bbool && (aplayground[actual-1].value < 9)) {}
if let browser execute codeblock error message via mozilla firebug:
"typeerror: aplayground[(actual - 1)] undefined"
bbool
error handler make sure second condition in line 11 doesn't checked still works if change last line to:
if (false && (aplayground[actual-1].value < 9)) {}
im working on ugly workaround increases amount of elements bypass error there must way more elegant way make browser ignoring undefined-error unfortunately im beginner in js please keep simple thx
don't use new boolean
, cast result boolean using this:
var bbool = !!(actual%width);
Comments
Post a Comment