title: Javascript get element index position in DOM array by class or id
body: <p>My situation</p>
  
  <pre><code>var domElements = document.body.getElementsByTagName('*');
  </code></pre>
  
  <p>Now I want to return the array item key - position of the element in the array - ( for example <code>domElements[34]</code>) searching in the array for the element with <code>id="asd"</code>.</p>
  
  <p>How can I achieve this?</p>
  
  <p>What if instead of ID I want to search trough <code>class="asd hey"</code> ?</p>
  
  <p>Any help appreciated, thank you!</p>
  
  <p>NB: Not in jquery, I need it in pure javascript in this case</p>