title: Why is the split() method approx. 2x slower when the result is pushed to an array?
body: <p>Consider the following code snippet:</p>
  <pre class="lang-js prettyprint-override"><code>function split() {
    let time = 0;
    let result = [];
    for (let i = 0; i &lt; 10 * 1000 * 1000; i++) {
      let start = performance.now();
      let words = &quot;foo bar baz&quot;.split(&quot; &quot;);
      let end = performance.now();
      time += (end - start);
      // result.push(words);
    }
    console.log(`Time needed: ${time}ms`);
  }
  </code></pre>
  <p>The output of this code is something like:</p>
  <p><code>Time needed: 2664ms</code>.</p>
  <p>However, with the line <code>// result.push(words);</code> uncommented, the output is something like:</p>
  <p><code>Time needed: 4991ms</code>.</p>
  <p>That's approx. 2x slower (note that I'm measuring only the time needed by <code>split()</code>, but not <code>push()</code>). Can someone explain me why?</p>