function extend(sub,sup)
{
//目地:实现只继承父类的原型对象
//1.用一个空函数据中转,目地进行中转
var F = new Function();
//2.实现空函数的的原型对象和超类的原型对象转换
F.prototype = sup.prototype;
//3原型继承
sub.prototype =sup.prototype;
//4.还原子类的构造器
sub.prototype.constructor = sub;
//5.保存父类的原型对象 一方面解耦,另一方面可以方便获得父类的原型对象
sub.superClass = sup.prototype;
}
function People(name,age)
{
this.name = name;
this.age = age;
}
People.prototype=
{
constructor:People,
sayHello:function()
{
alert('hello word')
}
}

function Boy(name,age,sex)
{
//People.call(this,name,age);
Boy.superClass.constructor.call(this,name,age);
this.sex = sex;
}

extend(Boy,People);
People.prototype=
{
sayHello:function()
{
alert('badd')
}
}
var b = new Boy('张三','21','男')
alert(b.name);
alert(b.age);
alert(b.sex);
b.sayHello();

最新文章

  1. spring mvc 传参数
  2. js和html5实现画板
  3. mysql随机获取一条或者多条数据
  4. 并发容器之CopyOnWriteArrayList(转载)
  5. HTML增加删除邮件(table)
  6. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
  7. C# 自己定义 implicit和explicit转换
  8. boke
  9. Linux入门(17)——Ubuntu16.04显示内存CPU网速等(System Monitor)
  10. python 识别图片上的数字
  11. BZOJ4479 : [Jsoi2013]吃货jyy
  12. 关于springMVC的日志管理
  13. 配置jboss为windows服务
  14. mysql学习笔记--数据库操作
  15. 文件上传和WAF的攻与防
  16. layui switch 开关监听 弹出确定状态转换
  17. INTERVAL
  18. [UE4]嵌套Canvas
  19. Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge
  20. GoldenGate 12c + Oracle 12c Multitenant Container databases

热门文章

  1. JMeter 5.4 打开测试计划 报错:Unexpected error
  2. mongo笔记
  3. [啃书] 第1篇 - 输入输出/变量类型/math函数
  4. 到底谁才需要Service Mesh?
  5. Spring Boot + MyBatis 多模块项目搭建教程
  6. [atARC063F]Snuke's Coloring 2
  7. [bzoj2789]Letters
  8. [luogu5294]序列
  9. idea配置MyBatis
  10. IE 跨域设置