Get the last character of a string

Benchmark created by Keith Cirkel on


Preparation HTML

<script>
  string = 'abc';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
To array then pop
string.split('').pop()
ready
String substr
string.substr(string.length - 1);
ready
String charat
string.charAt(string.length - 1);
ready

Revisions

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

  • Revision 1: published by Keith Cirkel on