var me = function (id, name, sex) { this.Id = id; this.Name = name; this.Sex = sex; this.ShowId = function () { alert(this.Id); }; this.ShowName = function () { alert(this.Name); }; this.ShowSex = function () { alert(this.Sex); };
}; var me2 = []; //me2.prototype.GetName = function () { alert("1212"); }; //me2.prototype.GetSex = function () { alert("mem"); }; //me2.prototype.GetId = function () { alert("05855"); } var me3 = function (id) { this.s=id; }; me3.prototype.sf = function () { alert(this.s); }; //me4继承父类me3 var me4 = function (id, d) { me3.call(this, d); this.id = id; }; me4.prototype = new me3(); //原型链中---此时不能有含参数的构造函数 me4.prototype.Say = function () { alert("父亲"+this.s+"自己的"+this.id); };
//有六继承五的用原型模式继承---原型链继承所以由原型模式编写的方法和属性 var me5 = function () { }; me5.prototype.color = "red"; me5.prototype.ShowColor = function () { alert(this.color); };
var me6 = function () { }; me6.prototype = new me5();//原型链中---此时不能有含参数的构造函数 var me = new me6(); me.ShowColor();
|