substr, charAt, substring, or square-bracket accessor? (v8)

Revision 8 of this benchmark created by aaafg on


Description

Get the first character of a string

Preparation HTML

<script>
  a = "abcdefghijklmnopqrstuvwxyz";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
substr
a.substr(0,1);
ready
charAt
a.charAt(0)
ready
substring
a.substring(0,1);
ready
square-bracket accessor
a[0]
ready

Revisions

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