Home > Web Front-end > JS Tutorial > body text

Recommended 3 articles about function forgery

黄舟
Release: 2017-06-15 16:33:41
Original
1009 people have browsed it

As mentioned above, we will not use the method based on function falsification alone to implement inheritance, but will use the method based on the prototype chain and function camouflage combination to implement inheritance. This inheritance method is also called pseudo-classical inheritance. Its idea is to use the prototype chain to inherit prototype properties and methods, and to inherit instance properties by borrowing constructors. In this way, function reuse is achieved by defining methods on the prototype, and each instance is guaranteed to have its own attributes. Looking at the following example, we first list the complete inheritance code based on prototype chain and function camouflage combination, and then perform memory model analysis on each step in the code. // first part function Parent(name){ This.color = ["red","blue"]; This.name = name; } Parent.prototype.talk = 

1. JavaScript object-oriented - inheritance based on prototype chain and function disguise combination

Recommended 3 articles about function forgery

Introduction: As mentioned above, we will not use function falsification alone to achieve inheritance, but will use prototype chain and function camouflage combination to achieve inheritance. . This inheritance method is also called pseudo-classical inheritance. Its idea is to use the prototype chain to inherit prototype properties and methods, and to inherit instance properties by borrowing constructors. In this way, function reuse is achieved by defining methods on the prototype, and each instance is guaranteed to have its own attributes.

2. JavaScript object-oriented - inheritance based on function forgery

Recommended 3 articles about function forgery

##Introduction: Since there are some shortcomings in the way of implementing inheritance based on the prototype chain, people have adopted another way to implement inheritance-implementing inheritance based on function forgery. The idea of ​​this technique is to call the parent class's constructor inside the child class's constructor.

3. Object-oriented_Function fake implementation inheritance

Introduction: Object-oriented_Function fake implementation inheritance

The above is the detailed content of Recommended 3 articles about function forgery. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template