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

Revision 10 of this benchmark created by atstek 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 ; i < l; i++  )
    val = obj[i];
ready

Revisions

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