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
{
...
}