这样一段代码:
function contact(name,telephone,email,page){
this.name=name;
this.telephone=telephone;
this.email=email;
this.page=page;
this.display=show;
}
问题1:this在这里是指contact吗,能说一下它具体的用法吗?
问题2:是如何知道contact的属性是那些,方法是那些?
        它的属性和方法在写法上面好像没有什么区别,是如何区分它们呢?
问题3:this.display=show;的display是如何来的呢?

解决方案 »

  1.   

    看着标题吓了一跳...
    我还在想java的问题怎么跑到.net里面了
    你问的是javascript吧
    这个函数没有上下文吗?
    看不明白哎....
    学习ING........
      

  2.   


    var name,telephone,email,pagefunction contact(name,telephone,email,page){
    this.name=name;
    this.telephone=telephone;
    this.email=email;
    this.page=page;
    this.display=show;
    }
      

  3.   

    这个不是函数,这个是javascript里面的类。
    你看到的是这个类的构造函数
    this.display正是这个类的成员变量。在构造函数里面这样声明。
      

  4.   

    private string gfName;
    makeLove(string gfName){
        this.gfName=gfName;
    }
    /*
    this.gfName代表private string gfName;
    而gfName代表形参fgName
    这个方法就可以把和你makelove的gf的名字保存
    */
      

  5.   

    在这里你可以把 function 看作是声明类的关键字class
    而 this.xxxxxx 可以看作是声明类的各个字段
    this也正像你说的 指代的就是contact
      

  6.   

    那么这句话:this.display=show; 系统又怎么知道它是方法呢,而且display在前面没有定义啊!
      

  7.   

    http://www.wd1001.com/new/webjc/zhuanzai/chap3-2.htm
      

  8.   

    JavaScript里面的变量是不需要事先声明的。直接在构造函数里面赋值就表示声明了。