.replace() vs. .split().join() vs .replaceAll() (v66)

Revision 66 of this benchmark created on


Setup

var mystring = 'okay.this.is.a.string';
  var regexObj = new RegExp(".","gm");
  var regexShort = /\./g;

Test runner

Ready to run.

Testing in
TestOps/sec
.replace(/\./g,' ')
result = mystring.replace(regexShort,' ');
ready
.replace(new RegExp(".","gm")," ")
result = mystring.replace(regexObj," ");
ready
.split('.').join(' ')
result = mystring.split('.').join(' ');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.