title: Could somebody explain how is it possible that the const tags array in createTags can be modified like this?
body: <p>It doesn't make sense to me that i can assign the input character by character to the tags array. createTags will execute right after every keyup event, how does it remember earlier inputs and how can i modify constant array?</p>
  <pre><code>textarea.addEventListener('keyup', (e) =&gt; {
      createTags(e.target.value)
  })
  
  const createTags = (input) =&gt; {
      const tags = input.split(',').filter(tag =&gt; tag.trim() !== '').map(tag =&gt; tag.trim())
      console.log(tags)
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>[&quot;t&quot;]
  [&quot;te&quot;]
  [&quot;tes&quot;]
  [&quot;test&quot;]
  [&quot;test&quot;]
  [&quot;test&quot;, &quot;t&quot;]
  [&quot;test&quot;, &quot;te&quot;]
  [&quot;test&quot;, &quot;tes&quot;]
  [&quot;test&quot;, &quot;test&quot;]
  [&quot;test&quot;, &quot;test&quot;]
  </code></pre>