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,901
  • 1
  • 11
  • 28
suchislife
  • 4,251
  • 10
  • 47
  • 78

0 Answers0