Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array(n).fill(char) vs Array.from({ length: n }, _ => char) vs manual loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array(n).fill(str)
238776.2 Ops/sec
Array.from({ length: n }, _ => str)
66171.8 Ops/sec
loop
97861.0 Ops/sec
Script Preparation code:
var str = "string"; var n = 1000;
Tests:
Array(n).fill(str)
var res = Array(n).fill(str)
Array.from({ length: n }, _ => str)
var res = Array.from({ length: n }, _ => str)
loop
var res = []; for (var i = 0; i < n; ++i) { res.push(str) }