type of a variable (v3)

Revision 3 of this benchmark created by Damion Grimfield on


Setup

var x
    var obj = {
      one: 1
    };
    var arr = ['one', 1];
    var func = function() {
        return 42;
        }

Test runner

Ready to run.

Testing in
TestOps/sec
obj typeof
x = (typeof obj == "object")
ready
obj instanceof
x = (obj instanceof Object)
ready
arr instanceof
x = (arr instanceof Array)
ready
arr toString
x = (toString.call(arr) == "[object Array]")
ready
func typeof
x = (typeof func == "function")
ready
func toString
x = (toString.call(func) == "[object Function]")
ready

Revisions

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