复主代码 代码如下: <p>// 방법일<br>var p0 = new Object();<br>p0.name = "xy";<br>p0.age = 20;<br>p0.sayName = function() { 경고 (이.이름); }<br>p0.showAgeAfterSomeYears = function(year) { return this.age year };<br>p0.sayName();<br>alert(p0.showAgeAfterSomeYears(10));</p> <p>// 방법이<br>function Person(){<br>}<br>var p1 = new Person();<br>p1.name = "xy";<br>p1.age = 20; <br>p1.sayName = function() { 경고(this.name); }<br>p1.showAgeAfterSomeYears = function(year) { return this.age year };<br>p1.sayName();<br>alert(p1.showAgeAfterSomeYears(10));</p> <p>// 방법삼<br>function Person(name,age){<br>this.name = name;<br>this.age = age;<br>this.sayName = function(){ Alert(this .이름); }<br>this.showAgeAfterSomeYears = function(year) { return this.age year };<br>}<br>var p2 = new Person("xy",20);<br>p2.sayName();<br>alert(p2.showAgeAfterSomeYears(10));</p> <p>// 방법사<br>var p3 = {<br>name : "xy",<br>age : 20,<br>sayName : function(){ Alert(this.name); },<br>showAgeAfterSomeYears : function(year) { return this.age year }<br>};<br>p3.sayName();<br>alert(p3.showAgeAfterSomeYears(10));</p> <p>// 방법五<br>var p4 = {};<br>p4.name = "xy";<br>p4.age = 20;<br>p4.sayName = function() { 경고(this .이름); }<br>p4.showAgeAfterSomeYears = function(year) { return this.age year };<br>p4.sayName();<br>alert(p4.showAgeAfterSomeYears(10));</p> <p>