Undefineds

JavaScript performance comparison

Test case created by Josh

Info

how to determine undefineds

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var myUndef, myNull, myValue, c;
    myNull = null;
    myValue = "artichoke";
    c = 1;
};
</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
Typeof strict Undefined
        if (typeof(myUndef) === "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Typeof coercive Undefined
        if (typeof(myUndef) == "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Double-comp Undefined
        if (myUndef == null && myUndef !== null) {
            c = 1;
        } else {
            c = 1;
        }
pending…
Typeof strict Null
        if (typeof(myNull) === "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Typeof coercive Null
        if (typeof(myNull) == "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Double-comp Null
        if (myNull == null && myNull !== null) {
            c = 1;
        } else {
            c = 1;
        }
pending…
Typeof strict Value
        if (typeof(myValue) === "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Typeof coercive Value
        if (typeof(myValue) == "undefined") {
            c = 1;
        } else {
            c = 1;
        }
pending…
Double-comp Value
        if (myValue == null && myValue !== null) {
            c = 1;
        } else {
            c = 1;
        }
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