<div class="htmlarea"> <textarea id="runcode30608"> <script language="javascript"><!-- function Lecture(name,teacher){ this.name=name; this.teacher=teacher; } Lecture.prototype.display=function(){ return this.teacher+"正在教幼儿园"+this.name+"\n"; } 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("语文","熊老师"), new Lecture("数学","钟老师") ]); alert(mySchedule.display()); // --></script> </textarea><br><input onclick="runEx('runcode30608')" type="button" value="运行代码"> <input onclick="doCopy('runcode30608')" type="button" value="复制代码"> <input onclick="doSave(runcode30608)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br>JavaScript面向对象编程<br><a href="http://www.jb51.net/article/13661.htm">http://www.jb51.net/article/13661.htm</a>