I saw several times in the project I'm working on, before setting the innerHtml element, the value is cleared before that, for example:
var foo = document.getElementById('foo') foo.innerHTML = ''; foo.innerHTML = '<span>Bar</span>'
I canβt find a good reason for this, simply because everyone in the team follows this βpracticeβ. As far as I understand, anyone can override the innerHtml property to perform an individual action, but besides this reason, is there another that I am missing?
Thanks!
EDIT: Updated code to avoid skewing (thanks @freefaller)
source share