title: Object have data but when opened it's empty
body: <p><strong>Framework:</strong> React</p>
  <p>So when I'm running the code below I console.log the objects.
  When looking at the first object is pushed to the array then it contains text but when looking at the array of objects afterward it's empty.</p>
  <p>The index 5 that is marked should be the object being pushed in the array in the red rectangle.</p>
  <p>How come?</p>
  <p><strong>The code</strong></p>
  <pre><code>    const SplitHtml = () =&gt; {
    const string =
      '&lt;p&gt;&lt;strong&gt;Add and edit text here. &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://www.google.com&quot;&gt;This is a link&lt;/a&gt; Select text to format it.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;'
  
    const stringArray = string.split(/(&lt;[^&gt;]+&gt;)/)
    let textArray = []
    let object = {}
  
    for (let i = 0; i &lt; string.length; i++) {
      console.log(i, object.text)
      if (stringArray[i] === undefined) break
      // Print out
      if (stringArray[i].startsWith(&quot;&lt;&quot;) &amp;&amp; object.text &amp;&amp; object.text.length &gt; 0) {
        console.log(i, &quot; push&quot;)
        textArray = [...textArray, object]
      }
      // Elements
      else if (stringArray[i] === &quot;&lt;p&gt;&quot;) {
        object.type = &quot;text&quot;
      } else if (stringArray[i] === &quot;&lt;h1&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;1&quot;
      } else if (stringArray[i] === &quot;&lt;h2&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;2&quot;
      } else if (stringArray[i] === &quot;&lt;h3&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;3&quot;
      } else if (stringArray[i] === &quot;&lt;h4&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;4&quot;
      } else if (stringArray[i] === &quot;&lt;h5&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;5&quot;
      } else if (stringArray[i] === &quot;&lt;h6&gt;&quot;) {
        object.type = &quot;headline&quot;
        object.importance = &quot;6&quot;
      } else if (stringArray[i].startsWith(&quot;&lt;a&quot;)) {
        object.type = &quot;link&quot;
      }
      // Style
      else if (stringArray[i] === &quot;&lt;strong&gt;&quot;) {
        object.bold = true
      } else if (stringArray[i] === &quot;&lt;/strong&gt;&quot;) {
        object.bold = false
      } else if (stringArray[i] === &quot;&lt;i&gt;&quot;) {
        object.italic = true
      } else if (stringArray[i] === &quot;&lt;/i&gt;&quot;) {
        object.italic = false
      }
      // Text
      else if (!stringArray[i].startsWith(&quot;&lt;&quot;)) {
        object.text = stringArray[i]
      }
    }
    console.log(textArray)
  }
  </code></pre>
  <p><strong>The screenshot</strong></p>
  <p><a href="https://i.stack.imgur.com/IhH4y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IhH4y.png" alt="enter image description here" /></a></p>