---
title: "javascript"
author: "suzuki"
date: "2011-01-27T15:18:17Z"
tags: []
categories: ["编程语言"]
slug: "javascript"
draft: false
lastmod: "2011-01-27T15:18:17Z"
id: 898323
url: "https://suzuki.iteye.com/blog/898323"
---

/\**  
\*/  
function Lecture(name,teacher){  
 this.name=name;  
 this.teacher=teacher;  
}  
Lecture.prototype.display=function(){  
 return this.name+","+this.teacher+"\\n";  
}  
/\**  
 Schedule的构造函数，以Lecture对象作为参数  
\*/  
function Schedule(lecture){  
 this.lecture=lecture;  
}  
Schedule.prototype.display=function(){  
 var str="";  
 for(var i=0;i&lt;this.lecture.length;i++){  
  str+=this.lecture\[i].display();  
 }  
 return str;  
}

var mySchedule=new Schedule([  
 new Lecture("chinanes","a"),  
 new Lecture("english","b"),  
 new Lecture("math","c")  
]);  
alert(mySchedule.display());