In the process of switching my native javascript code to JQuery, I've noticed that even after deleting a variable that is referenced by getElementById
, other part of code was still able to reference that element.
Why didn't I get an error? How's this good practice in ANY scenario?
container1.innerHTML = "How did I not cause an error?";
<body>
<div id="container1"></div>
</body>