in operator or array

JavaScript performance comparison

Test case created


Perf check for in operator over object or array.

Preparation code

Benchmark.prototype.setup = function() {
    var obj ={};
    for(var i=0;i<200;i++) {
       obj[i.toString()]= i.toString() + "~~~~~~~~";

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
keys array
var keys = Object.keys(obj);

for(var i=keys.length;i>0;i--) {
 var prop = obj[keys[i-1]];
in operator
for(var i in obj) {
  var prop = obj[i];

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

Compare results of other browsers


Comment form temporarily disabled.

Add a comment