继承的4种基本方式
2016-03-06 16:19
399 查看
1、构造继承
2、原型继承
3、实例继承
比较奇特的继承,跟直接执行函数一样,得到的是返回值。
4、拷贝继承
拷贝继承,满大街都是,分深层拷贝和浅层拷贝两种。
function Parent(){ this.name = "Parent"; } function Child(){ Parent.call(this); } var child = new Child(); console.log(child.name);
2、原型继承
function Parent(){ this.name = "Parent"; } function Child(){ } Child.prototype = new Parent(); var child = new Child(); console.log(child.name);
3、实例继承
function ArrayCollection(){ return []; } var ac = new ArrayCollection();
比较奇特的继承,跟直接执行函数一样,得到的是返回值。
4、拷贝继承
拷贝继承,满大街都是,分深层拷贝和浅层拷贝两种。
相关文章推荐
- 98.Validate Binary Search Tree
- Android 数据库文件存取至储存卡的方法
- 观察者模式——Android控件的交互事件监听
- java 内部类总结
- CMake之CMakeLists.txt编写入门
- 保存文件时,解决内存暴涨 方法之-- FileHandle
- 剑指offer——年龄排序问题
- PAT_Basic 1009
- [LeetCode]233. Number of Digit One
- 盲并遗忘着-利用应用交付透析大型网站日志
- bzoj4008: [HNOI2015]亚瑟王
- 剑指offer——年龄排序问题
- Java多线程下载的实现方法
- 构建之法阅读笔记01
- 本学期阅读计划
- 构建之法(五)
- Log4j最佳实践
- 软工大作业·源物语(一)
- 内核定时任务timer_list
- NBUT 1655 [1655] 木块拼接