JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://github.com/arieh/Class.def/raw/master/Source/Class.def.js"></script>
<ul id='res'></ul>
JavaScript
new Class.def('Person') << new Class({
age : 20
,name : ''
, el : null
, initialize : function(name,age){
this.name = name;
this.el = $('res');
if (age) this.age = age;
this.log();
}
, log:function(){
new Element('li',{
html:'My Name Is '+this.name+' and my age is '+this.age
}).inject(this.el);
}
});
new Class.def('Child') << new Person({
age : 5
, initialize:function(name,age){
if (age>15) throw "Child cannot be older than 15";
this.parent(name,age);
}
});
new Class.def('Elder') << new Person({
age:70
, initialize:function(name,age){
if (age<60) throw "Elders cannot be younger than 60";
this.parent(name,age);
}
});
var bob = new Person('Bob',25);
var keef = new Child('Keef');
var alice = new Elder('Alice');