JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/sapienlab/lang-def/master/def.js"></script>
<h1>See the console</h1>
JavaScript
var Animal = def({
name: null,
speak: function () { return 'I am ' + this.name; }
});
var Cat = def(Animal, {
speak: function() {
return this.super('speak') + ', the Cat';
}
});
var Dog = def(Animal, {
speak: function() {
return this.super('speak') + ', the Dog';
}
});
var cat = new Cat({ name: 'Canela' });
var dog = new Dog({ name: 'Doky' });
console.log(Cat);
console.log(cat);
cat instanceof Cat;
// -> true
cat instanceof Animal;
// -> true
dog instanceof Dog;
// -> true
dog instanceof Animal;
// -> true
console.log(cat.speak());
// -> 'I am Canela, the Cat'