typeof+null vs real typeof

Benchmark created by Enzo on


Preparation HTML

<script>

_typeof = (function() {
        
        var list = {

                '[object Null]': 'null',
                '[object Undefined]': 'undefined',
                '[object Object]': 'object',
                '[object Function]': 'function',
                '[object Array]': 'array',
                '[object Number]': 'number',
                '[object String]': 'string',
                '[object Boolean]': 'boolean',
                '[object Symbol]': 'symbol'

        };


        return function ( type ) {

                return list[ Object.prototype.toString.call( type ) ];

        };


})();
</script>

Setup

var n=null;
    var o={};

Test runner

Ready to run.

Testing in
TestOps/sec
typeof+null
(typeof n=='object' && n!==null);
(typeof o=='object' && o!==null);
ready
real typeof
(_typeof(n)=='object');
(_typeof(o)=='object');
ready

Revisions

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