//原型链继承
function Parent() {
this.name = 'per';
}
function Child() {
this.age = 20;
}
Child.prototype = new Parent();
var child = new Child();
console.log(child.name + " " + child.age)//per 20
//构造函数继承
 function Parent(age) {
this.name = 'person';
this.age = age;
}
function Child(age) {
Parent.call(this, age)
}
var child = new Child(20)
console.log(child.name + " " + child.age)//per 20
// 组合继承
 function Parent(age) {
this.name = 'per';
this.age = age;
}
Parent.prototype.sayAge = function () {
return this.name + ' age is ' + this.age;
}
function Child(age) {
Parent.call(this, age)
}
Child.prototype = new Parent();
var child = new Child(21);
console.log(child.sayAge())//per age is 21

最新文章

  1. MVP社区巡讲-云端基础架构:12月5日北京站 12月12日上海站
  2. jee websocket搭建总结
  3. An invalid character [32] was present in the Cookie value
  4. 使用Ant构建struts2 web工程,自动编译,打包成war
  5. 移动Web 开发中的一些前端知识收集汇总
  6. java list三种遍历方法性能比較
  7. java笔记之类和对象
  8. MegaCli监控RAID磁盘健康信息
  9. 文件操作2 cp mv rm
  10. Mysql Innodb体系结构
  11. 自动生成proto Js语句
  12. 爬取IP
  13. 获取当前人IP地址
  14. 如何用JS获取页面上的所有标签
  15. Docker命令分类及使用场景分布(脑图)
  16. Python拷贝文件脚本
  17. 【python】网络编程-UDP协议套接字
  18. MBIST:用于嵌入式存储器的可测试设计技术
  19. SQL Server 2014与TFS 2013的错误(TF53001:管理员已取消数据库操作)
  20. js的一些妙用

热门文章

  1. Spring5.0源码学习系列之浅谈循环依赖问题
  2. 四:Redis五大数据类型
  3. MFC详解
  4. Tomcat Web服务器与常用Web服务器
  5. @Autowired自动装配原理
  6. CSS 背景常用属性
  7. 计算机&编程语言发展史
  8. Mac下载工具folx如何下载常用的软件
  9. 从维基百科等网站复制数据和公式到MathType里编辑
  10. 添加mysqli扩展