批量实现面向对象的实例代码

(编辑:jimmy 日期: 2024/10/13 浏览:2)

复制代码 代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>批量实现面向对象的实例</title>
<script type="text/javascript">
window.onload = function(){
function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.showName = function(){
alert(this.name);
};
function extend(parent,child,method){
function a(){
parent.apply(this,arguments);
child.apply(this,arguments);
};
for(var i in parent.prototype){
a.prototype[i]=parent.prototype[i];
}
for(var i in method){
a.prototype[i] = method[i];
}
return a;
};//参数为父级构造函数,子级构造函数,子级方法
var int = extend(Person,function(name,age,job){
this.job = job;
},
{
showjob:function(){
alert(this.job);
}
}
);
var oc=new int('侠客',24,'工作');
oc.showjob();
}
</script>
</head>
<body>
<h1>面向对象继承实例</h1>
<p>开始展示批量实现面向对象的实例</p>
</body>
</html>
一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。