oop实现方法与属性继承
2015-12-20 15:54
375 查看
<script>
/*父类 Person*/
function Person(name,age){
this.name=name;
this.age=age;
}
Person.prototype.showName=function(){
this.name;
};
Person.prototype.showAge=function(){
return this.age;
};
function Worker(name,age,job){
Person.apply(this,arguments); /*继承属性*/
this.job=job;
}
Worker.prototype=new Person();/*继承方法*/
Worker.prototype.constructor=Worker;
Worker.prototype.showJob=function(){
return this.job;
};
/*父类 Person*/
function Person(name,age){
this.name=name;
this.age=age;
}
Person.prototype.showName=function(){
this.name;
};
Person.prototype.showAge=function(){
return this.age;
};
function Worker(name,age,job){
Person.apply(this,arguments); /*继承属性*/
this.job=job;
}
Worker.prototype=new Person();/*继承方法*/
Worker.prototype.constructor=Worker;
Worker.prototype.showJob=function(){
return this.job;
};
相关文章推荐
- 部署和调优 2.3 tomcat中JDK安装
- 快速搭建网站教程
- ldd3 sbull编译遇到的问题 解决(部分)方法
- linux下获取域名的IP地址
- debian安装nginx-1.9.9和php-7.0.1
- shell脚本错误:syntax error near unexpected token '$'\r''
- Win7 Eclipse调试Centos Hadoop2.2-Mapreduce(转)
- awk 输出值到多个变量
- linux 设置wifi热点
- 2.在虚拟机上用iso制作yum源,及问题repomd.xml找不到解决
- Linux w 命令
- scala-31:Option使用和实现内幕源码揭秘
- 怎么搭建个人博客网站——我的建站过程
- Linux安装pecl和pear
- linux 环境变量设置三种方法和查看
- linux学习笔记
- 利用CDLinux里面的水滴破解路由器密码的教程
- linux 下载安装tomcat
- 侧滑手势移除控制器,pop
- Copy-->Mutable Copy