function  Person()
{
this.name="plglenn";
say=function(){alert("hello csdn");}
}Person.prototype.name1="plglenn1";
Person.prototype.say=function(){alert("hello csdn1");}能不能谈谈访问性 

解决方案 »

  1.   

    function  Person() 

    this.name="plglenn"; 
    say=function(){alert("hello csdn");} 

    var p= new Person() ;每当用 new Person() 创建一个对象的时候this.name="plglenn"; 
    say=function(){alert("hello csdn");} 都会开辟新的内存空间而Person.prototype.name1="plglenn1"; 
    Person.prototype.say=function(){alert("hello csdn1");} 则不会访问性 类似于 c# 中的 实例的属性 与 类的属性
      

  2.   

    <script>
    function  Person()
    {
    this.name="plglenn";
    this.say=function(){alert("hello csdn"); }
    }Person.prototype.name1="plglenn1";
    Person.prototype.say1=function(){alert("hello csdn1");} var p=new Person();
     ;</script>这个实例好像都能访问,
    但是用Person访问应该有限制的吧?
      

  3.   

    Person.prototype.name1="plglenn1";
    Person.prototype.say=function(){alert("hello csdn1");}
    如何用Person  访问  这四个量 。person  我测试了,没有问题!
      

  4.   


    name 和 say 通过 Person  是访问不到,因为它是用this 设置的, 也就是设置的是 this 的属性这里的this 不是 Person (但有可能是Person).name1  和 say1 通过 Person.prototype.name1 访问