for in vs object keys map

JavaScript performance comparison

Test case created by 3y3

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var o = {};
    function f(e){++o[e]}
    for(var i=0;i<1000;o[i]=i++);
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
for in
for(var i in o)++o[i];
pending…
map
Object.keys(o).map(function(e){++o[e]});
pending…
map predefined
Object.keys(o).map(f);
pending…

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

Compare results of other browsers

0 comments

Add a comment