check-js-type (v7)

Revision 7 of this benchmark created on


Description

check js type

Setup

var _toString = {}.toString;  // cache it god damn it!!
    var theValue = {}; // also, a literal object _in the test_ may or may NOT render the same code - a literal benchmark is kinda fucking retarded - would NEVER be used in real code.

Test runner

Ready to run.

Testing in
TestOps/sec
typeof
theValue !== null && typeof(theValue) === "object" && !Array.isArray(theValue);
ready
typeof 2
theValue != null && typeof(theValue) == "object" && !Array.isArray(theValue);
ready
constructor
theValue.constructor === Object && !Array.isArray(theValue) && theValue.constructor !== Function;
ready
Object.prototype.toString.call theValue (cached)
theValue && _toString.call(theValue) === '[object Object]';
ready
theValue.toString()
theValue && theValue.toString() === '[object Object]';
ready

Revisions

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