"Type of undefined" vs "=== undefined" (v44)

Revision 44 of this benchmark created by Oscar Campbell on


Setup

var a = 1, b = true, c = "c", d = [], e = {}, f = {a:1, b:null, c:undefined}, u, global = window;

Test runner

Ready to run.

Testing in
TestOps/sec
typeof undefined
typeof a === 'undefined';
typeof b === 'undefined';
typeof c === 'undefined';
typeof d === 'undefined';
typeof e === 'undefined';
typeof f.a === 'undefined';
typeof f.b === 'undefined';
typeof f.c === 'undefined';
typeof f.lost === 'undefined';
typeof global.nonexistant === 'undefined';
ready
=== undefined
a === undefined;
b === undefined;
c === undefined;
d === undefined;
e === undefined;
f.a === undefined;
f.b === undefined;
f.c === undefined;
f.lost === undefined;
global.nonexistant === undefined;
ready
=== undefined(local)
a === u;
b === u;
c === u;
d === u;
e === u;
f.a === u;
f.b === u;
f.c === u;
f.lost === u;
global.nonexistant === u;
ready
void 0
a === void 0;
b === void 0;
c === void 0;
d === void 0;
e === void 0;
f.a === void 0;
f.b === void 0;
f.c === void 0;
f.lost === void 0;
global.nonexistant === void 0;
ready
falsy
Boolean(a) === false;
Boolean(b) === false;
Boolean(c) === false;
Boolean(d) === false;
Boolean(e) === false;
Boolean(f.a) === false;
Boolean(f.b) === false;
Boolean(f.c) === false;
Boolean(f.lost) === false;
Boolean(global.nonexistant) === false;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.