check-js-type (v6)

Revision 6 of this benchmark created by Eser Ozvataf 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
typeof theValue === 'object';
ready
instanceof
theValue instanceof Object;
ready
constructor
theValue.constructor === Object;
ready
Object.prototype.toString.call theValue (cached)
_toString.call(theValue) === '[object Object]';
ready
theValue.toString()
theValue.toString() === '[object Object]';
ready
constructor w/ undefined check
theValue !== undefined && theValue.constructor === Object;
ready

Revisions

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