title: What is the difference between querySelectorAll() and getElementsByClassName()
body: <p>Apparently these two functions are similar, which is more performative? Which one should I use? What's the difference between the two?</p>
  
  <p><strong><em>document.querySelectorAll()</em></strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function funDOM() {
      var x = document.querySelectorAll(".example");
      var i;
      for (i = 0; i &lt; x.length; i++) {
          x[i].style.backgroundColor = "red";
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;body onload="funDOM()"&gt;
      &lt;div&gt;
          Doubts &lt;span class="example"&gt;red&lt;/span&gt;
      
      &lt;/div&gt;
      &lt;p class="example"&gt;red&lt;/p&gt;
      
      
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong><em>document.getElementsByClassName()</em></strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function funDOM() {
      var x = document.getElementsByClassName("example");
      var i;
      for (i = 0; i &lt; x.length; i++) {
          x[i].style.backgroundColor = "red";
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;body onload="funDOM()"&gt;
      &lt;div&gt;
          Doubts &lt;span class="example"&gt;red&lt;/span&gt;
      
      &lt;/div&gt;
      &lt;p class="example"&gt;red&lt;/p&gt;
      
      
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>