title: What is difference between creating HTML by innerHTML and document.createElement?
body: <p>I wonder what is the difference between creating HTML by innerHTML and document.createElement?</p>
  
  <p>For example, I want to create a new DIV inside of parent DIV.</p>
  
  <p>Let's assume parent DIV has no content.</p>
  
  <p>One option is <code>parent.innerHTML = '&lt;div&gt;&lt;/div&gt;';</code></p>
  
  <p>Another option is <code>parent.append(document.createElement('div'));</code></p>
  
  <p>I was asked this during an interview.</p>
  
  <p>Personally, I think that creating an HTML object gives us the flexibility to add more elements later on compared to using innerHTML.</p>
  
  <p>Wondering if there is a better reason.</p>