indexOf vs lastIndexOf

Benchmark created on


Preparation HTML

<script>
  var s = "";
  for (var i = 0; i < 10000; i++) {
   if (i === 4999) s += "bar";
   else s += "foo"
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
s.indexOf("bar");
ready
lastIndexOf
s.lastIndexOf("bar");
ready

Revisions

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