<div class="codetitle"> <span><a style="CURSOR: pointer" data="90510" class="copybut" id="copybut90510" onclick="doCopy('code90510')"><u>コードをコピー</u></a></span> コードは次のとおりです:</div> <div class="codebody" id="code90510"> <br><script language="javascript" type="text/javascript"><BR> = 関数 {<BR>オブジェクト <BR> this.way = function ( str) {<BR>} <BR> // オブジェクトに属性値を追加します <BR> name.prototype.xing = "123"; <🎜 🎜 ><BR>ローカル プロパティとメソッドは静的でのみ使用できます。タイプ <BR> alert(Name.shi); 🎜> function Name1() {<BR> Name1.prototype.add = function () { }<BR> this.way = function () { }<br> Name1.prototype .shu = "その他";<br> } <BR> <BR> Name.Addd2(); //静的メソッドの呼び出し<BR> var name = new Name();<BR> name.Add (); //メソッドを呼び出すオブジェクト<BR> name.Way( ; メソッド*/<>/*インスタンスオブジェクトはプロトタイプを使用できません;*/<BR> <br> // (2) JavaScript 継承 <br> //親クラス <BR> 関数クラス () { <BR> this.name = "名前";<BR> this.method = function () {<BR>alert("メソッド");<BR> }<BR> } <BR> //サブクラス<BR> function Class1() {<BR> this.name1 = "name1";<BR> this.method1 = function () {<BR>alert("method1");<BR> } <BR> }<BR> . name1);<BR> obj.method();<BR> /Subclass<BR> function Class2() {<BR> this.name2 = "name2";<BR> this.method2 = function () {<BR> alert("method2");<BR> }<BR> }<BR> Class2.prototype = new Class(); //Inherit<BR> Class2.prototype.name = "updateName"; //Rewrite the attributes of the parent class<BR> Class2.prototype.method = function () { //Override the method of the parent class<BR> ; obj2.method(); //Show UpdateMethod<BR> alert(obj2.name2); <BR> obj2.method2(); arr = new Array();<BR> arr.push({ "name": "1", "age": 12, funA: function () { } });<BR> arr.push({ "name" : "2", "age": 13 });<BR> arr.push({ "name": "3", "age": 14 });<BR> for (var i = 0; i < arr.length; i ) {<BR> alert(arr[i].name); > Way: function () { } <BR> };<BR> </script><br><br> </div>