function Lecture(name, teacher) {
this.name = name;
this.teacher = teacher;
} Lecture.prototype.display = function () {
return this.teacher + " is teacher " + this.name;
} function Schedule(lectures) {
this.lectures = lectures;
} Schedule.prototype.display = function () {
var str = "";
for (var i = 0; i < this.lectures.length; i++) {
str += this.lectures[i].display + " ";
}
return str;
}
var mySchedule = new Schedule([new Lecture("Gym", "Mr.Smith"), new Lecture("Math", "Mr.Jones"), new Lecture("English", "TBD")]); alert(mySchedule.display());
请大家看上面有哪里错啦
解决方案 »
- 新手求助,jquery代码简写
- jQuery $(document).ready() 的疑问
- 如何保存值(JSON,JQ,AJAX)
- JavaScript连接数据库问题
- ckeditor4开发插件 怎么在dialog中显示一个html网页内容
- js控制图片比例缩放问题
- 怎么用javascript使链接,form,script 失效?
- 十万火急,在线等待:给我一个源代码,详细请进。
- 在CSS中的filter : Chroma方法能不能使某一个范围内的颜色都变为透明的?
- 窗口每滑动一次,为什么$(window).scroll()运行的次数不是1?
- jquery 下一个点击事件的写法
- js 如何判断控件替换word书签成功
Schedule.prototype.display = function () {
var str = "";
for (var i = 0; i < this.lectures.length; i++) {
str += this.lectures[i].display() + " ";
}
return str;
}
Schedule.prototype.display = function () {
var str = "";
for (var i = 0; i < this.lectures.length; i++) {
str += this.lectures[i].display + " ";
}
return str;
}改为:
str += this.lectures[i].display() + " ";看看