undef-or-typeof-undef

Benchmark created by rmunson on


Description

If a variable is guaranteed to exist, though may have a value of undefined... which test is faster?

Preparation HTML

<script>
var STR_UNDEFINED="undefined",
    UNDEFINED;
</script>

Setup

var defined="thing",
        notdefined;

Test runner

Ready to run.

Testing in
TestOps/sec
typeof undefined
(typeof defined === STR_UNDEFINED);
(typeof notdefined === STR_UNDEFINED);
ready
undef equals
(defined === UNDEFINED);
(notdefined === UNDEFINED);
ready

Revisions

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

  • Revision 1: published by rmunson on