is.js 836 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var RTL$ = {
  2. extend: function extend(methods){
  3. methods.__proto__ = this.prototype; // make instanceof work
  4. // to see constructor name in diagnostic
  5. var result = methods.init;
  6. methods.constructor = result.prototype.constructor;
  7. result.prototype = methods;
  8. result.extend = extend;
  9. return result;
  10. }
  11. };
  12. var m = function (){
  13. var Base = RTL$.extend({
  14. init: function Base(){
  15. }
  16. });
  17. var Derived1 = Base.extend({
  18. init: function Derived1(){
  19. Base.prototype.init.bind(this)();
  20. this.field1 = 0;
  21. }
  22. });
  23. var Derived2 = Derived1.extend({
  24. init: function Derived2(){
  25. Derived1.prototype.init.bind(this)();
  26. this.field2 = 0;
  27. }
  28. });
  29. var pb = null;
  30. var pd1 = null;
  31. var pd2 = null;
  32. var b = false;
  33. pd2 = new Derived2();
  34. pb = pd2;
  35. pd1 = pd2;
  36. b = pb instanceof Derived1;
  37. b = pb instanceof Derived2;
  38. b = pd1 instanceof Derived2;
  39. }();