title: JavaScript: image.src or setAttribute() - Which way shall I use to change an image?
body: <p>There are at least two ways in JavaScript to change an image:</p>
  
  <p>Using the setAttribute() method.</p>
  
  <pre><code>img.setAttribute('src', 'imgs/' + imgs[i] + '.png');
  </code></pre>
  
  <p>Writing the src.attribute of the image-element directly.</p>
  
  <pre><code>img.src = 'imgs/' + imgs[i] + '.png'
  </code></pre>
  
  <p>Both ways work. I've tried it out.</p>
  
  <p>But:</p>
  
  <p><strong>Should I prefer one way over the other and why?
  Or does it matter at all and I can use what I personally prefer?</strong></p>