"Type of undefined" vs "=== undefined"

JavaScript performance comparison

Revision 6 of this test case created by Mihai Bazon

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = 1, b = true, c = "c", d = [], e = {}, u;
};
</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 undefined
typeof a === 'undefined';
typeof b === 'undefined';
typeof c === 'undefined';
typeof d === 'undefined';
typeof e === 'undefined';
pending…
=== undefined
a === undefined;
b === undefined;
c === undefined;
d === undefined;
e === undefined;
 
pending…
=== undefined(local)
a === u;
b === u;
c === u;
d === u;
e === u;
pending…
void 0
a === void 0;
b === void 0;
c === void 0;
d === void 0;
e === void 0;
pending…
[][0]
a === [][0];
b === [][0];
c === [][0];
d === [][0];
e === [][0];
pending…
0[0]
a === 0[0];
b === 0[0];
c === 0[0];
d === 0[0];
e === 0[0];
pending…
function(){}()
a === function(){}();
b === function(){}();
c === function(){}();
d === function(){}();
e === function(){}();
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