is.js 975 B

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