String charAt vs. bracket notation

Benchmark created by XP1 on


Setup

function testCharAt(string, index)
    {
        return string.charAt(index);
    }
    
    function testBracketNotation(string, index)
    {
        return string[index];
    }

Test runner

Ready to run.

Testing in
TestOps/sec
String charAt
testCharAt("cat", 1);
ready
String bracket notation
testBracketNotation("cat", 1);
ready

Revisions

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