1

I'm discovered this behavior in the following example:

console.log(myId);

// What I expected:
// Uncaught ReferenceError: …

// Result (chrome 78 windows 10):
// <div id="myId">…</div>
<div id="myId">

Is this behavior normal/expected? Should it be used/avoided? From my testing it seems to work on chrome, firefox and edge, but not on safari mobile. I couldn't find anything about this behavior and never saw it used, and the devtools (and code editors) doesn't autocomplete it like most other variables, it's really odd.

Bar Yemini
  • 48
  • 5
  • I would assume that you're accessing the document object, which is global, or the window object, which is also global. – Kobe Nov 20 '19 at 15:48

0 Answers0