日期:2014-05-16 浏览次数:20430 次
<script> function subClass(){ } subClass.prototype = { Name: "这个是原始值" } function myClass() { //构造函数 } myClass.prototype = { ID: 1, Name: "johnson", SubObj: new subClass(), showMessage: function() { alert("ID: " + this.ID + ", Name: " + this.Name + "SubObj.Name:" + this.SubObj.Name); } } var obj0 = new myClass(); obj0.showMessage(); var obj1 = new myClass(); obj1.SubObj.Name = "After 修改过的"; obj1.showMessage(); var obj2 = new myClass(); obj2.showMessage(); </script>