In my code, I see this:
if (document.getElementById(\'xx\') !=null) {
//do stuff
}
if xx element is not defined, will this
Yes it will return null if it's not present you can try this below in the demo. Both will return true. The first elements exists the second doesn't.
Demo
Html
Javascript:
if (document.getElementById('xx') !=null)
console.log('it exists!');
if (document.getElementById('xxThisisNotAnElementOnThePage') ==null)
console.log('does not exist!');