87,838
社区成员




function sayhello(alerttxt){
try {
this fullname=fullname;
alert(fullname+alerttxt);
} catch (err) {
alert(err.description);
}
}
function testPerson(){
try {
mybrother=new person("徐白白",24,"bule");
document.getElementById('name').innerHTML=mybrother.fullname;
document.getElementById('age').innerHTML=mybrother.age;
document.getElementById('eyecolor').innerHTML=mybrother.eyecolor;
document.getElementById('b4').innerHTML=mybrother.sayhello("这是我的名字!");
} catch (err) {
// handle errors here
alert(err.description);
}
}
function person(fullname,age,eyecolor)
{
this fullname=fullname;
this age=age;
this eyecolor=eyecolor;
this sayhello=sayhello;
}
//专门用一个函数来初始化对象。
function Student(name,age,sex)
{
this._name=name;
this._age=age;
this._sex=sex;
}
function sayhello(alerttxt){
try {
this.fullname=fullname;
alert(fullname+alerttxt);
} catch (err) {
alert(err.description);
}
}
function testPerson(){
try {
mybrother=new person("徐白白",24,"bule");
document.getElementById('name').innerHTML=mybrother.fullname;
document.getElementById('age').innerHTML=mybrother.age;
document.getElementById('eyecolor').innerHTML=mybrother.eyecolor;
document.getElementById('b4').innerHTML=mybrother.sayhello("这是我的名字!");
} catch (err) {
// handle errors here
alert(err.description);
}
}
function person(fullname,age,eyecolor)
{
this.fullname=fullname;
this.age=age;
this.eyecolor=eyecolor;
this.sayhello=sayhello;
}