falsey check vs typeOf check

Benchmark created by Mark on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>

Setup

var undefinedObj, 
        obj = {peek:true, d: true};
    x = 1;

Test runner

Ready to run.

Testing in
TestOps/sec
1
if (typeOf(undefinedObj) !== 'object') ++x;
ready
2
if (typeOf(obj) !== 'object') ++x;
 
ready
3
if (!undefinedObj || typeOf(undefinedObj) !== 'object') ++x;
ready
4
if (!obj || typeOf(obj) !== 'object') ++x;
ready

Revisions

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