title: Why are we taught to assign document.getElementById("id") to a variable and then use that variable with a property?
body: <p>Why do tutorials teach us to get an element's property in two statements such as this:</p>
  
  <pre><code>var sample = document.getElementById("sample");
  var mySample = sample.value;
  </code></pre>
  
  <p>Instead of doing it all in one statement like this?</p>
  
  <pre><code>var mySample = document.getElementById("sample").value;
  </code></pre>
  
  <p>I understand that if you needed to access several different properties of the same element, it would result in less code and also make it easier to read but why do people do this even when there's only one property being accessed?</p>