JSFiddle - React, Tailwind, and code Playground
by rgthree
JavaScript
var Base = new Class({
options: {
base:true
},
getType: function(){
console.log('base!');
}
});
var TypeA = new Class({
Extends: Base,
options: {
TypeA:true
},
initialize: function(){
this.type = 'a';
},
getType: function(){
this.parent();
return 'A';
},
imA: function(){
return 'A';
}
});
var TypeB = new Class({
Extends: Base,
options: {
TypeB:true
},
initialize: function(){
this.type = 'b';
},
getType: function(){
this.parent();
return 'B';
},
imB: function(){
return 'B';
}
});
console.log('-----');
var ta = new TypeA();
console.log(ta);
console.log(ta.type, ta.getType(), ta instanceof TypeA, ta instanceof TypeB);
var tb = new TypeB();
console.log(tb);
console.log(tb.type, tb.getType(), tb instanceof TypeA, tb instanceof TypeB);
var tc = new TypeA();
tc.__proto__ = TypeB.prototype;
console.log(tc);
console.log(tc.type, tc.getType(), tc instanceof TypeA, tc instanceof TypeB);