这是给类help添加原型方法添加完毕以后,可以这么用var hel = new help();
hel.SetJ();

解决方案 »

  1.   

    new help();                //生成对象,无引用,故无义
    help.prototype.SetJ=SetJ;  //采用原型方式追加help类的方法SetJfunction help(){           //定义help类
      this.SetJ=SetJ;          //此句与help.prototype.SetJ=SetJ重复,可省略
     }function SetJ(a,b,c)       //定义SetJ方法
    {
    ......
    }
    备注:
    仍何类定义,对象定义都会在整段js语句被解析前先行解析.故help,SetJ可先引用后定义
    ============运行如下代码体会
    <SCRIPT LANGUAGE="JavaScript">
    help.prototype.SetJ=SetJ;function help(){
    }function SetJ(a,b,c)
    {
    alert(a);
    }var ab = new help();
    ab.SetJ(2,3,5)
    </SCRIPT>