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

Revision 51 of this benchmark created by Simon on


Setup

var a = 1,
      b = true,
      c = "c",
      d = [],
      e = {},
      noop = function(){},
      u,
      undef = 'undefined';

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
null
a == null && a !== null;
b == null && b !== null;
c == null && c !== null;
d == null && d !== null;
e == null && e !== null;
ready
null2
a !== null && a == null;
b !== null && b == null;
c !== null && c == null;
d !== null && d == null;
e !== null && e == null;
ready
noop
a === noop();
b === noop();
c === noop();
d === noop();
e === noop();
ready
typeof with string in var
typeof a === undef;
typeof b === undef;
typeof c === undef;
typeof d === undef;
typeof e === undef;
ready

Revisions

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