Script Preparation code:
x
 
class BaseClass {
    constructor(val) {
        this._bVal = val;
    }
    get bVal() {
        return this._bVal;
    }
    set bVal(value) {
        this._bVal = value;
    }
}
class ParentClass extends BaseClass {
    constructor(val) {
        super(val)
        this._pVal = val + '_parent';
    }
    get pVal() {
        return this._pVal;
    }
    set pVal(value) {
        this._pVal = value;
    }
}
class ChildClass extends BaseClass {
    constructor(val) {
        super(val)
        this._cVal = val + '_child';
    }
    get cVal() {
        return this._cVal;
    }
    set cVal(value) {
        this._cVal = value;
    }
}
class AnotherClass {
    constructor(val) {
        this._bVal = val;
    }
    get bVal() {
        return this._bVal;
    }
    set bVal(value) {
        this._bVal = value;
    }
}
var VarBaseClass = BaseClass;
var VarAnotherClass = AnotherClass;
var t = new ChildClass('test');
Tests:
  • success - instanceof

     
    t instanceof VarBaseClass
  • success - isPrototypeOf

     
    VarBaseClass.prototype.isPrototypeOf(t)
  • error - instanceof

     
    t instanceof VarAnotherClass
  • error- isPrototypeOf

     
    VarAnotherClass.prototype.isPrototypeOf(t)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    success - instanceof
    success - isPrototypeOf
    error - instanceof
    error- isPrototypeOf

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Chrome 89 on Windows
View result in a separate tab
Test name Executions per second
success - instanceof 4271940.0 Ops/sec
success - isPrototypeOf 4088848.8 Ops/sec
error - instanceof 4258877.5 Ops/sec
error- isPrototypeOf 4002993.8 Ops/sec