undefined vs null check (v5)

Revision 5 of this benchmark created by dh on


Description

Check the speed comparing typeof, null, undefined with and without strict.

Setup

var u = undefined;
    var t = true;
    
    function nop() {}

Test runner

Ready to run.

Testing in
TestOps/sec
undefined-undefined
if (u == undefined) nop();
ready
undefined-undefined strict
if (u === undefined) nop();
ready
undefined-null
if (u === null) nop();
ready
true-!undefined strict
if (u !== undefined) nop();
ready
typeof undefined
if (u) nop();
ready
void 0
if (u === void 0) nop();
ready

Revisions

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