fork download
  1. class A {}
  2. class B extends A {}
  3.  
  4. const o1 = new A();
  5. // true, because Object.getPrototypeOf(o1) === A.prototype
  6. console.log(o1 instanceof A);
  7. // false, because B.prototype is nowhere in o1's prototype chain
  8. o1 instanceof B;
  9.  
  10. const o2 = new B();
  11. // true, because Object.getPrototypeOf(Object.getPrototypeOf(o2)) === A.prototype
  12. console.log(o2 instanceof A);
  13. // true, because Object.getPrototypeOf(o2) === B.prototype
  14. console.log(o2 instanceof B);
  15.  
Success #stdin #stdout 0.03s 19020KB
stdin
Standard input is empty
stdout
true
true
true