lastIndexOf vs. charAt (v5)

Revision 5 of this benchmark created by caitp on


Description

Compare lastIndexOf with a startIndex of 0 vs multiple calls to charAt

Preparation HTML

<script>
  var s = 'xhdhdfhdfhdfjfjfgjgf';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
if(s.lastIndexOf('xh', 0) === 0) {}
ready
charAt
if(s.charAt(0) === 'x' && s.charAt(1) === 'h') {}
ready

Revisions

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