// Inheritance
function RunSampleE() {
var Dog = function (id, name, age, color) {
Dog.prototype.Color = color;
Dog.prototype.Age = age;
Dog.prototype.ID = id;
Dog.prototype.Name = name;
Dog.prototype.toString = function () {
return this.ID + '; ' + this.Name + '; ' + this.Age + '; ' + this.Color;
}
Dog.prototype.Bark = function () { alert('Hoow, Hoow'); }
}
// var buddy = new Dog(1, 'Buddy', 3, 'White');
var buddy = new Dog.prototype.constructor(1, 'Buddy', 3, 'White');
alert(buddy);
buddy.Bark();
Dog.prototype.New = function () { alert('Say new'); }
buddy.New();
}
Wednesday, October 6, 2010
OOP Javascript Inheritance
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment