I noticed that when I assign some id to a DOM element, I can then reference that element in javascript, just by treating its id as a javascript variable name.
For example
console.log(myDiv);
<div id="myDiv">some text</div>
Is there a difference between referencing a DOM element with document.getElementById(id) and just its id?
Can I expect this behaviour in all browsers?