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.
let string = 'Hello World';
let newString = string.split(' ').join('_');
//newString: Hello_World
The other way to solve this is the replace function:
let string = 'Hello World';
let newString = string.replace(/ /g,"_");
//newString: Hello_World
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.