JavaScript - isEmptyObject

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var o = {};
   
    function isObjectEmpty(o) {
        for(var p in o) {
            if(o.hasOwnProperty(p)) return false;
        }
        return true;
    }
};
</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
JSON.stringify
JSON.stringify(o) === '{}';
pending…
Object.keys
Object.keys(o).length === 0;
pending…
for-in loop (via function)
isObjectEmpty(o);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment