javascript
来源:互联网 发布:跳跃网络服务器爆炸 编辑:程序博客网 时间:2024/04/29 07:42
以下代码是从pro javascript techniques书中拷贝出来的 <script language="JavaScript">
/**//*
* ex:Listing 1-1
*/
//Lecture类的构造函数
function Lecture( name, teacher ) {
this.name = name;
this.teacher = teacher;
}
//声明Lecture类的方法display
Lecture.prototype.display = function(){
return this.teacher + " is teaching " + this.name;
};
//Schedule类的构造函数
function Schedule( lectures ) {
this.lectures = lectures;
}
//声明Lecture类的方法display
Schedule.prototype.display = function(){
var str = "";
for ( var i = 0; i < this.lectures.length; i++ )
str += this.lectures[i].display() + "<br/>";
return str;
};
// 创建Schedule类的对象mySchedule
var mySchedule = new Schedule([
new Lecture( "Gym", "Mr. Smith" ),
new Lecture( "Math", "Mrs. Jones" ),
new Lecture( "English", "TBD" )
]
);
document.writeln( mySchedule.display() );
</script>
- Javascript
- JavaScript
- javascript
- javascript
- javascript
- javascript
- javascript
- JavaScript
- javascript
- JavaScript
- Javascript
- javascript
- javascript
- JavaScript
- javascript
- javascript
- JavaScript
- javascript
- 沙砾与黄金
- 搜集的网站
- 开始写博客了
- 确定自己研究方向的办法(话题提出人:廖义林)
- liferay startup error
- javascript
- Unix的引导安装(话题提出人:廖义林)
- 2006年度学习总结
- 中间件概念(话题提出人:宋文鹏)
- 谁知道"the flash mind reader"为什么这么准 好神奇呀
- JS中Opener的另外的作用-不提示就关闭父窗口
- Oracle 10G(话题提出人:黄俊峰)
- Sky做客《鲁豫有约》
- 新手入门:不应该有的想法