2

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>
Jasdeep Singh
  • 7,113
  • 1
  • 7
  • 25
suchislife
  • 3,318
  • 9
  • 41
  • 68

0 Answers0