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

Revision 3 of this benchmark created on


Setup

var a = 1, b = true, c = "c", d = [], e = {}, u, n = null;
    const U = undefined;
    const N = null;

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';
ready
=== undefined
a === undefined;
b === undefined;
c === undefined;
d === undefined;
e === undefined;
 
ready
=== undefined(local)
a === u;
b === u;
c === u;
d === u;
e === u;
ready
void 0
a === void 0;
b === void 0;
c === void 0;
d === void 0;
e === void 0;
ready
const
a === U;
b === U;
c === U;
d === U;
e === U;
ready
== null
a == null
b == null
c == null
d == null
e == null
ready
=== null
a === null
b === null
c === null
d === null
e === null
ready
=== null & === undefined
a === null || a === undefined
b === null || b === undefined
c === null || c === undefined
d === null || d === undefined
e === null || e === undefined
ready
== null (local)
a == n
b == n
c == n
d == n
e == n
ready
=== null (local)
a === n
b === n
c === n
d === n
e === n
ready
Null/undefined (local)
a === n || a === u
b === n || b === u
c === n || c === u
d === n || d === u
e === n || e === u
ready
== u
a == u
b == u
c == u
d == u
e == u
ready

Revisions

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