Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
string.at(-1) vs string[string.length-1]
Couple of methods to get the last character of a string
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 127
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
length-1
29.7M/s
at(-1)
16.2M/s
View exact numbers
Test name
Executions per second
✓
length-1
29,659,322 Ops/sec
at(-1)
16,172,470 Ops/sec
Tests:
at(-1)
const string = "banana_pie"; string.at(-1);
length-1
const string = "banana_pie"; string[string.length-1]