title: Why is document.getElementById not needed?
body: <p><strong>1) Question 1</strong></p>
  
  <p>The following example works without using "document.getElementById('myId')". Why is that and is it OK to skip "document.getElementById('myId')"?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Javascript question&lt;/title&gt;
  
  &lt;script&gt;
  window.onload = function(){
      myId.style.color = 'red';
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id=myId&gt;
  &lt;p&gt;Make this color red.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>2) Question 2</strong></p>
  
  <p>I usually store browser-objects to reduce DOM traversal (see example below). Will it be more DOM traversal if I dont store the ID in a variable or is it some how already a variable?</p>
  
  <pre><code>window.onload = function(){
  
  var myId = document.getElementById('myId'); /* stored ID that will be used multiple times */
  
  myId.style.color = 'red';
  }
  </code></pre>
  
  <p>Thanks!</p>