Transform all object values to Array

Benchmark created on


Setup

const obj = {};
for (let i = 0; i < 10000; ++i) {
	obj['property-' + i] = i;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Using for...in
const arr = new Array();
for(let o in obj) {
	arr.push(o);
}
ready
Using Object.values()
const arr = Object.values(obj);
ready
Using for and index
const arr = new Array();
for(let i = 0; i < 10000; ++i) {
	arr.push(obj['property-' + i]);
}
ready

Revisions

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