这样一段代码:
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是如何来的呢?
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是如何来的呢?
我还在想java的问题怎么跑到.net里面了
你问的是javascript吧
这个函数没有上下文吗?
看不明白哎....
学习ING........
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;
}
你看到的是这个类的构造函数
this.display正是这个类的成员变量。在构造函数里面这样声明。
makeLove(string gfName){
this.gfName=gfName;
}
/*
this.gfName代表private string gfName;
而gfName代表形参fgName
这个方法就可以把和你makelove的gf的名字保存
*/
而 this.xxxxxx 可以看作是声明类的各个字段
this也正像你说的 指代的就是contact