obj.property iteration

JavaScript performance comparison

Test case created by unomi

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var propcount = 0, myObjConst = function(){};
  myObjConst.prototype.ohno = "ignoremeplz";
  var myObj = new myObjConst;
  for(var i = 100;i--;){myObj[i] = i;}
  

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
prototype.hOP
for (var key in myObj) {
     if(Object.hasOwnProperty.call(myObj,key)){
       if(key === "ohno"){ throw new Error('Oh Noes'); }
     }
   }
pending…
precheck, myObj.hOP
if(myObj){
  for (var key in myObj) {
     if(myObj.hasOwnProperty(key)){
        if(key === "ohno"){ throw new Error('Oh Noes'); }
     }
   }
}
pending…
precheck, predeclare, myObj.hOP
if(myObj){
  var key;
  for (key in myObj) {
     if(myObj.hasOwnProperty(key)){
        if(key === "ohno"){ throw new Error('Oh Noes'); }
     }
   }
}
pending…
keys.forEach - nostalgia-free
Object.keys(myObj).forEach(function(key){
  if(key === "ohno"){ throw new Error('Oh Noes'); }
});
pending…
oh no
for (var key in myObj) {
    if(key === "ohno"){ throw new Error('Oh Noes'); }
   }
pending…
precheck, predeclare, myObj.hOP no work-load
if(myObj){
  var key;
  for (key in myObj) {
     if(myObj.hasOwnProperty(key)){
        
     }
   }
}
pending…
keys.forEach - nostalgia-free - no work
Object.keys(myObj).forEach(function(key){
  
});
pending…

Compare results of other browsers

Revisions

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

0 Comments