<div class="codetitle"> <span><a style="CURSOR: pointer" data="58329" class="copybut" id="copybut58329" onclick="doCopy('code58329')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code58329"> <br><script type="text/javascript"> <BR>function people(name){ <BR>this.name=name; <BR>this.introduce=function(){ //对象方法 <BR>alert("my name is"+this.name); <BR>} <BR>} <br><br>people.run=function(){ //类方法 <BR>alert("i can run"); <BR>} <br><br>people.prototype.jump=function(){ //原型方法 <BR>alert("i can jump") <BR>} <br><br>var p1=new people("vincent"); <BR>p1.introduce(); <BR>people.run(); //c#中的static <BR>p1.jump(); <BR></script> <br> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="50043" class="copybut" id="copybut50043" onclick="doCopy('code50043')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code50043"> <br>function common(){ <br>//..... <br>} <br>common.prototype=new Object(); <br> </div> <br>Object对象是common的原型,Object对象的属性和方法复制到了common上