Object.keys in loop

Benchmark created on


Description

Measuring performance difference between calling Object.keys in a loop's conditional statement in every iteration and caching the value of Object.keys and looping over the value

Setup

const arr = new Array(10000).fill(1);

Test runner

Ready to run.

Testing in
TestOps/sec
Calling Object.keys in for loop condition statement
for(let key in Object.keys(arr)){}



ready
Assigning value of the Object.keys to a constant and iterating over that value instead of calling Object.value on every iteration
const keys = Object.keys(arr);
for(let key in keys){}

ready

Revisions

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