//定义 People 对象 var People = function () { }; People.prototype = { Height: 175, Walk: function () { alert("People are walking..."); } } //定义 Me 对象 var Me = function () { }; //设置 Me 的 prototype 属性为 People 对象 Me.prototype = new People(); //将创建 Me 对象的引用指回给 Me Me.prototype.constructor = Me; //修改 Height 属性 Me.prototype.SetHeight = function (v) { Me.prototype.Height = v; } //新增 Stop 动作 Me.prototype.Stop = function () { alert("I'm Stop."); } var m = new Me(); //结果为 People are 175cm tall. alert("People are " + m.Height + "cm tall."); m.SetHeight(185); //结果为 I'm 185cm tall. alert("I'm " + m.Height + "cm tall."); //结果为 People are walking... m.Walk(); //结果为 I'm Stop. m.Stop(); var y = new Me(); //结果为 You're 185cm tall. alert("You're " + y.Height + "cm tall.");