In my code, I see this:
if (document.getElementById('xx') !=null) {
//do stuff
}
if xx
element is not defined, will this evaluate to true or false?
Should I write:
if (document.getElementById('xx'))
to be safe?
console.log(document.getElementById('xx') ) evaluates to null.
document.getElementById('xx') !=null evaluates to false
You should use document.getElementById('xx') !== null
as it is a stronger equality check.