Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
forEach vs For of and startsWith
(version: 0)
Taken from https://jsbench.me/welq15149d/1. Testing forEach vs For of, while also testing first character
Comparing performance of:
.startsWith forEach vs .charAt forEach vs [0] forEach vs .match forEach vs .startsWith vs .charAt vs [0] vs .match
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const strs = [ '', '*', '#', '*short', '#short', '*'.padEnd(2500, '-'), '#'.padEnd(2500, '-'), ];
Tests:
.startsWith forEach
strs.forEach(str => {str.startsWith('*')})
.charAt forEach
strs.forEach(str => {str.charAt(0) === '*'})
[0] forEach
strs.forEach(str => {str[0] === '*'})
.match forEach
strs.forEach(str => {str.match(/^\*/)})
.startsWith
for(const str of strs) {str.startsWith('*')}
.charAt
for(const str of strs) {str.charAt(0) === '*'}
[0]
for(const str of strs) {str[0] === '*'}
.match
for(const str of strs) {str.match(/^\*/)}
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
.startsWith forEach
.charAt forEach
[0] forEach
.match forEach
.startsWith
.charAt
[0]
.match
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?