Prototype of sub class is instance of base class.
var Person = function() {};
Person.prototype = {
name : "hoge",
toString : function() {
window.alert(this.name);
}
};
var Programmer = function() {};
Programmer.prototype = new Person();
var shunsuk = new Programmer();
shunsuk.name = "shunsuk";
shunsuk.toString();
No comments:
Post a Comment