<div class="codetitle"> <span><a style="CURSOR: pointer" data="9145" class="copybut" id="copybut9145" onclick="doCopy('code9145')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code9145"> <br><script type="text/javascript"> <br>var test = { <br>numA: 10, <br>objB: {}, <br>arrC: [], <br>init: function(){ <br>alert(this.numA); <br>}, <br>sayHi: function(이름){ <br>alert("hello " 이름); <br>}, <br>sayHelloWorld: function(){ <br>this.sayHi("world"); <br>}, <br>get: function(){ <br>var self = this; <br>this.objB.alertNumA = function(){ <br>alert(self.numA); <br>} <br>} <br>}; <br>var TestFunc = function(){ <br>alert("저는 testFunc입니다"); <br>}; <br>TestFunc.prototype = { <br>extFunc: function(){ <br>alert("이 확장 함수의 numB는 " this.numB); <br>}, <br>numB: 10 <br>}; <br>test.init(); <br>test.sayHi("qingming"); <br>test.sayHelloWorld(); <br>test.get(); <br>test.objB.alertNumA(); <br>var testFunc = new TestFunc(); <br>testFunc.extFunc(); <br></script> <br> </div>