日期:2014-05-16 浏览次数:20317 次
function Man(name,age) { //公有字段 this.Name = name; //私有字段 var age; //私有方法 function show() { alert(gm.Name + " is " + age + " years old"); } //公有方法 this.Show = function () { show(); }; var gm = this; } var m = new Man('jack', 10); m.Show();
function Man(name, age) { //公有字段 this.Name = name; //私有字段 var age; } //本来是私有方法 Man.prototype.show = function () { alert(this.Name + " is " + age + " years old"); } //公有方法 Man.prototype.Show = function () { this.show(); };