javascript 面向对象的经典实例代码
作者:bea
<script language="javascript"><!-- function Lecture(name,teacher){ this.name=name; this.teacher=teacher; } Lecture.prototype.display=function(){ return this.teacher+"正在教幼儿园"+this.name+""; } function Schedule(l
<script language="javascript"><!--
function Lecture(name,teacher){
this.name=name;
this.teacher=teacher;
}
Lecture.prototype.display=function(){
return this.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("语文","熊老师"),
new Lecture("数学","钟老师")
]);
alert(mySchedule.display());
// --></script>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
JavaScript面向对象编程
http:///article/13661.htm
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 为指定元素增加样式的js代码
- 动态调整textarea中字体的大小代码
- 可以用来搜索当前页面内容的js代码
- javascript弹出窗口 window.open使用方法以及参数说明分析篇
- javascript setTimeout和setInterval 的区别
- javascript OFFICE控件测试代码
- JavaScript Cookie 直接浏览网站分网址
- JavaScript Cookie显示用户上次访问的时间和次数
- JavaScript 利用Cookie记录用户登录信息
- JavaScript Cookie的读取和写入函数
- jquery 双色表格实现代码
- javascript检测(控制 )上传文件大小
- IE浏览器打印的页眉页脚设置解决方法
- jQuery Selectors(选择器)的使用(六、属性篇)
- JQuery 表单中textarea字数限制实现代码
- 测试JavaScript字符串处理性能的代码
- javascript 混合的构造函数和原型方式,动态原型方式
- JavaScript 常见对象类创建代码与优缺点分析
- javascript prototype原型操作笔记