Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Three ways of converting a JavaScript set to an array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4.1 Mobile/22E252 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.4.1
Device Platform:
Mobile
Date tested:
one year ago
Array from
4.8M/s
Destructuring
4.5M/s
forEach
3.1M/s
View exact numbers
Test name
Executions per second
✓
Array from
4,820,150 Ops/sec
Destructuring
4,522,356 Ops/sec
forEach
3,119,817 Ops/sec
Script Preparation code:
var set = new Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]);
Tests:
Array from
return Array.from(set);
Destructuring
return [...set]
forEach
let a = []; set.forEach(x => a.push(x)); return a;