In my code, I see this:
if (document.getElementById(\'xx\') !=null) { //do stuff }
if xx element is not defined, will this
xx
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.
document.getElementById('xx') !== null