<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
< head >
< title > 1.1编写自己得对象 </ title >
< script language =javascript > ...
var bingo=new Object();
bingo.exam=new Object();
bingo.exam.Student=Student;
function Student(s,j)
...{
this.first=s;
this.last=j;
this.getFirstName=returnfirt;
this.getLastName=returnlast;
this.toString=returnString;
}
function returnfirt()
...{
return this.first;
}
function returnlast()
...{
return this.last;
}
function returnString()
...{
return this.first+" "+this.last;
}
function main()
...{
var student = new bingo.exam.Student("Jim", "Green");
window.alert(student.getFirstName());
window.alert(student.getLastName());
window.alert(student);
}
</ script >
</ head >
< body onload ="main()" >
</ body >
</ html >
< head >
< title > 1.1编写自己得对象 </ title >
< script language =javascript > ...
var bingo=new Object();
bingo.exam=new Object();
bingo.exam.Student=Student;
function Student(s,j)
...{
this.first=s;
this.last=j;
this.getFirstName=returnfirt;
this.getLastName=returnlast;
this.toString=returnString;
}
function returnfirt()
...{
return this.first;
}
function returnlast()
...{
return this.last;
}
function returnString()
...{
return this.first+" "+this.last;
}
function main()
...{
var student = new bingo.exam.Student("Jim", "Green");
window.alert(student.getFirstName());
window.alert(student.getLastName());
window.alert(student);
}
</ script >
</ head >
< body onload ="main()" >
</ body >
</ html >