面向对象继承实例(a如何继承b)
2013-07-01 21:28
295 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>面向对象继承实例</title> <script type="text/javascript"> window.onload = function(){ function parent(age,name){ this.age = age; this.name = name; } parent.prototype.show = function(){ alert('父级方法'); } function child(age,name,job){ parent.apply(this,arguments); this.job = job; } (function(){ for(var i in parent.prototype){ child.prototype[i]=parent.prototype[i] } })(); var b = new parent(14,'侠客行'); var a = new child(15,'狼侠','侠客'); a.show(); } </script> </head> <body> <h1>面向对象继承实例</h1> <p>经常看到面试题有关继承问题 a如何继承b 决定写一下,其实继承就是继承父级的属性和方法</p> </body> </html>
相关文章推荐
- 面向对象继承实例(a如何继承b)
- 面向对象继承实例(a如何继承b问题)(自写)
- 面向对象继承实例(a如何继承b问题)(自写)
- javascript 中面向对象实现 如何继承
- 一个经典实例理解继承与多态原理与优点(附源码)---面向对象继承和多态性理解得不够深刻的同学请进
- java面向对象实例:小明去考试1.2.加入了继承多态
- 2.0 面向对象 类与实例(关键字)、封装、继承、多态(虚方法,抽象类,抽象方法,接口)
- 虚基类继承与非虚基类继承时对象是如何初始化问题
- PHP面向对象深入理解之二(封装、继承、多态、克隆)
- 黑马程序员_java面向对象总结【3】(继承、接口和多态)
- C++primer学习:面向对象程序设计(3):访问控制与继承
- 面向对象的程序设计-3-继承
- 写给前端面试者(面向初级) 如何写好技术简历 —— 实例、模板及工具 总结关于前端面试、写技术简历
- 面向对象之继承
- 面向对象--继承、接口、抽象
- 面向对象思考及go实现继承与多态
- 黑马程序员面试题面向对象一(封装,构造函数,this,static,单例设计模式,继承)
- js面向对象和继承
- ABAP OO 面向对象语法 ---实例看 "=" 与 "?=" 的区别