Hot.typeof vs typeof

Benchmark created on


Preparation HTML

<script>
  var hot = (function (undefined) {
        var toString = Object.prototype.toString;
        
        var hot = function () {
                //....
        };
        
        var typeOf = hot.typeOf = function (val) {
                var type = typeof val;  //Ok if not then let's define type using typeof statement
                
                if (type !== "object") return type; //If type not equal to object then ok but else
                
                if (val === null) return "null"; //Maybe val is null ?          
                if (val.length !== undefined) return "array"; //Maybe it's array?
                
                return "object"; //Ok, it's object
        };
        
        return hot;
  })();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
typeof
typeof 42;
typeof [];
typeof {};
typeof null;
typeof "string";
ready
hot.typeOf
hot.typeOf(42);
hot.typeOf([]);
hot.typeOf({});
hot.typeOf(null);
hot.typeOf("string");
ready

Revisions

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