for example the following code
if (obj.attr1.attr2.attr3.attr4 == 'constant') return;
need to rewrite how
if (obj.attr1
&& obj.attr1.attr2
&& obj.attr1.attr2.attr3
&& obj.attr1.attr2.attr3.attr4 == 'constant') return;
I correctly understood that each level needs to be tested individually or is there a syntax shortcut for this?
if it was a single shot, it would not be a problem, but this construct permeates my code.
from the answers, here is the solution I have in place:
try {if (obj.attr1.attr2.attr3.attr4! = 'const') throw 'nada'; } catch (e) {
nonblockAlert ('Relevant Message');
return
};
this works because the error caused by the absence of attr breaks with local throw (). the problem is that the syntax does not fit into the will with normal, if then another control.
source share