indexof and replace

Benchmark created on


Preparation HTML

<script>
  var s = "stringwithoutbackslashes",
      s2 = "string\\with\\back\\slashes";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf then replace
s.indexOf("//") > 0 && s.replace(/\\/g, "");
s2.indexOf("//") > 0 && s2.replace(/\\/g, "");
ready
just replace
s.replace(/\\/g, "");
s2.replace(/\\/g, "");
ready

Revisions

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