Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
instanceof check 422278.8 Ops/sec
constructor check 519055.8 Ops/sec
Script Preparation code:
x
 
function Ticket(id) {
  this._id = id;
}
var testTicket = new Ticket(1);
var count = 1000;
Tests:
  • 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 === Ticket) {
        continue;
      }
    }