Object.keys().forEach() vs for in (v6)

Revision 6 of this benchmark created on


Setup

var obj = {}, i = 10000, val;
    
    while ( i-- )
        obj[i] = i;

Test runner

Ready to run.

Testing in
TestOps/sec
Object.keys().forEach()
Object.keys(obj).forEach(function(obj){
    val = obj;
});
ready
for-in
for ( var key in obj )
    val = obj[key];
ready
Objest.keys() -> for loop
var keys = Object.keys(obj), i = 0; l = keys.length;
for (; i < l; i++  )
    val = obj[i];
ready
Object.keys()
var keys = Object.keys(obj);
ready

Revisions

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