Since you set node.bar
equal to false
, (node.foo && node.bar)
will evaluate to false
whether the properties are attached or not. Rather than checking if those properties are true
, you should check whether they are undefined:
if (typeof node.foo !== 'undefined' && typeof node.bar !== 'undefined')
{
...
}
else
{
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…