面向对象之Javascript浅析(下)
你很可能已经从代码清单中看出,大部门面向对象基本要素以及那个存在,不过它们是以不同于其它更常见的面向对象语言的方式组织起来的。你可以创建对象的构造函数、可以添加方法,也可以访问对象的属性。一个使用了上面两个类的例子如下所示:
代码清单: 给用户提供一个课程列表
//创建一个新的Schedule对象,保存在变量 mySchedule 中
var mySchedule = new Schedule([
//创建一个Lecture对象的数组,作为Schedule对象的唯一参数传入
new Lecture("English","Mr.Realure"),
new Lecture("Chinese","Realure"),
new Lecture("Math","Yonghong")
]);
var mySchedule = new Schedule([
//创建一个Lecture对象的数组,作为Schedule对象的唯一参数传入
new Lecture("English","Mr.Realure"),
new Lecture("Chinese","Realure"),
new Lecture("Math","Yonghong")
]);
//以弹出窗口的形式显示这个课程信息
alert(mySchedule.display());
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

你的链接,我已经加上,望能加上