![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
继承
文章平均质量分 66
code_ja
哈哈
展开
-
深入理解原型链的本质
原型链是作为实现继承的主要方法,基本思想是利用原型让一个引用类型继承另一个引用类型的属性和方法。 实现原型链的代码如下:function Super() { this.property = true; } Super.prototype.getSuperValue = function() { return this.property; }; function Sub() {原创 2016-06-29 15:55:28 · 1335 阅读 · 0 评论 -
原型链实现继承的几种模式
原型链很强大,可以用来实现继承,但也存在一些问题。其中最主要的问题是来自包含引用类型值的原型。看如下例子:function Super() { this.colors = ['red', 'blue', 'green']; } function Sub() { } Sub.prototype = new Super(); var instance1 = new Sub(); instance原创 2016-07-02 13:31:29 · 1696 阅读 · 0 评论