title: Split and join function or the replace function
body: <p>I'm curious which function is faster in JavaScript and I can't find a solution to this problem. Lets take a simple string and replace all spaces with underscores.</p>
  <pre><code>let string = 'Hello World';
  let newString = string.split(' ').join('_');
  //newString: Hello_World
  </code></pre>
  <p>The other way to solve this is the replace function:</p>
  <pre><code>let string = 'Hello World';
  let newString = string.replace(/ /g,&quot;_&quot;);
  //newString: Hello_World
  </code></pre>
  <p>Both ways (in my opinion) are fine to read. I'm wondering which way is faster at this moment (May 2018). I found some answers but these are outdated and I was wondering if they have increased the performance of newer browsers.</p>