Script Preparation code:
x
 
function Ticket(id) {
  this._id = id;
}
var testTicket = new Ticket(1);
var count = 1000;
Tests:
  • typeof check

     
    for (var i = 0; i < count; i += 1) {
      if (typeof testTicket === 'object') {
        continue;
      }
    }
  • instanceof check

     
    for (var i = 0; i < count; i += 1) {
      if (testTicket instanceof Ticket) {
        continue;
      }
    }
  • constructor check

     
    for (var i = 0; i < count; i += 1) {
      if (testTicket.constructor.name === 'Ticket') {
        continue;
      }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    typeof check
    instanceof check
    constructor check

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Windows
View result in a separate tab
Test name Executions per second
typeof check 904218.9 Ops/sec
instanceof check 475233.9 Ops/sec
constructor check 78911.7 Ops/sec