Proper test for property

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var obj = Object.create(null, {
        foo : {
            get : function() {
                return 'value';
            }
        }
    });
   
    var propName = 'bar';
     
   
};
</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
in
if (propName in obj) {}
pending…
direct compare
if (obj.bar === undefined) {}
pending…
direct typeof
if (typeof obj.bar === "undefined") {}
pending…
indexer compare
if (obj[propName] === undefined) {}
pending…
indexer typeof
if (typeof obj[propName] === "undefined") {}
pending…
direct implicit
if (obj.bar) {} // caution: false negatives for 'false-y' values
pending…
indexer implicit
if (obj[propName]) {} // caution: false negatives for 'false-y' values
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