No way,it's mean "private"like it?
:)

解决方案 »

  1.   

    给你一个我最近写的一个例子(Circle相当个新创建的类):
    function Circle (xPoint, yPoint, radius) {
        this.x = xPoint;  // 圆心的 x 坐标。
        this.y = yPoint;  // 圆心的 y 坐标。
        this.r = radius;  // 圆的半径。
        this.pi=Math.PI;
        Circle.prototype.area=function(){
    return this.pi * this.r * this.r;
        }
    }function window_onload() {
    var aCircle = new Circle(12,12,2);
    alert(aCircle.area());
    }
      

  2.   

    do you understand?<html>
    <script>
    function test()
    {
     var aa="test1"
     this.test2=function()
      {
       var aa="test2"
       alert(aa)
      }
      
    }
    var f = new test();
    f.test2();
    </script>
    </html>
      

  3.   

    except you exposure it (public)e.g.<html>
    <script>
    function test()
    {
     test.prototype.test2 = test2;
     var aa="test1";
     function test2()
      {
       var aa="test2";
       alert(aa);
      }
    }
    new test().test2();
    </script>
    </html>
      

  4.   

    <html>
    <script>
    function test()
    {
     var aa="test1"
     this.test2=test2;
     function test2()
      {
       var aa="test2"
       alert(aa)
      }
    }
    var a=new test();
    a.test2();
    </script>
    </html>