1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
// create an empty Employee class
var Employee = Class.create();
// extend Person
Object.extend(Employee.prototype,Person.prototype);
// extend Employee interface
Object.extend(Employee.prototype, {
initialize: function(name,salary) {
// super constructor
Person.prototype.initialize.call(this, name);
this.salary = salary;
},
show: function() {
alert(this.name + earns + this.salary);
}
});
var myemployee = new Employee(Ken, 100000000)
// alerts "Ken earns 100000000"
myemployee.show(); |
Partager