Empty object tests

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code

<input id="output" />
<script>
  var obj = {a:1,b:2,c:3,d:4},
      out = document.getElementById('output');

  // Add method to get object size (length)
  Object.isEmpty = function(o) {
    var n = 0;
    for (var i in o) {
      return false;
    }
    return true;
  };
</script>
    

Preparation code output

<input id="output" />

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
Object.isEmpty
out.value = Object.isEmpty(obj);
pending…
JSON.stringify
out.value = (JSON.stringify(obj) == '{}');
pending…
Object.keys().length
out.value = (Object.keys(obj).length == 0);
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