I. Common objects and Function objectsIn JavaScript, everything is the object! But the objects are also different. is divided into ordinary objects and function objects, object, function is JS self-contained functions object. The following examples illustrateFunction F1 () {};var F2 = function () {};var F3 = new Function (' str ', ' Console.log (str) ');var O3 = new F1 ();var O1 = {};var O2 =new Object ();Console.log (typeof Object); functionConsole.log (typeof Function); functionConsole.log (ty
Learning javascript object-oriented understanding of javascript prototype and prototype chain, javascript object-oriented
Let's take a look at a picture and sort it out.
I. Basic Concepts Prototype chain]Each constructor has an object. The prototype object contains a pointer to the constructor, And the instance contai
PrefaceJavaScript does not contain the traditional class inheritance model, but uses the prototypal prototype model.Although this is often mentioned as a disadvantage of JavaScript, prototype-based inheritance models are more powerful than traditional class inheritance models. It is easy to implement the traditional class inheritance model, but it is much more difficult to implement
Details about prototype and prototype chain in JavaScript -- Item15
Those who have used JavaScript must be familiar with prototype. However, this makes it difficult for beginners to understand that a function has a prototype attribute, you can add functions for it for instance access. The rest is unclear. Recently, I r
PS One sentence: Eventually choose Csdn to organize the publication of the knowledge points of these years, the article parallel migration to CSDN. Because CSDN also support markdown grammar, Ah!OverviewPrototype mode is a creation design pattern that returns a new instance by copying an already existing instance, rather than creating a new instance. The copied instance is what we call a prototype, which is customizable.
Each function created in JavaScript has a prototype (prototype) attribute, which is a pointer to an object that is used to contain properties and methods that can be shared by all instances of a particular type. If the literal meaning is understood, then prototype is the prototype object of the object instance created
In JavaScript, inheritance is a wonderful way to implement interface inheritance, and can only rely on prototype inheritance.
Prototype chaina prototype is an object, and an instance created through a constructor has a pointer to the prototype's properties and methods. In this way, the instance object takes the property method of the constructor and the property
function person () { this. Name = ' John '; } var New Person (); function () { Console.log (this. Name); }; Person.say (); // Hello,johnThe code is very simple, and the person prototype object defines a common say method, although this occurs after the instance is constructed, but since the prototype method has been declared before the call, each subsequent instance will have
prototype is a more difficult concept in JavaScript, the prototype related properties are also more, the object has "prototype" property, the Function object has "prototype" property, the prototype object has "constructor" property.First, the initial knowledge of the prototy
Prototype originated from French. The software standards are translated as "prototype", which represents the initial form of things and also contains the meaning of models and templates. The prototype concept in JavaScript exactly reflects the content of the word. We cannot understand it as a pre-declared concept of prototype
Constructor: constructor of an object. It is a function.
Prototype: the prototype of the constructor. Only functions have this attribute.
Isprototypeof: If object a exists in the original model chain of object OBJ, A. isprototypeof (OBJ) returns true, and OBJ must inherit the attributes of.
_ PROTO __: the prototype chain of the access object is the upper-l
Prototype Mode description
Description: Use a prototype instance to copy the creation of a new customizable object, a new object that does not need to know the exact process of the original object creation;
Process: Prototype => new Protoexam => clone to New Object;
Use related code:
Copy Code code as follows:
function
How to Understand JS prototype chain and JS prototype chain
Before talking about the prototype chain, we must first understand the relationship between user-defined functions and functions. What are the links between constructors, prototypes, and instances? In fact, all functions are Function instances. There is a prototype
In javascript learning notes (8), we mainly learned how to create objects and add object attributes and methods when using javascript object-oriented programming. When using object-oriented programming, the inheritance relationships between objects are indispensable! Prototype is an important method to implement javascript inheritance!
Let's take a look at the following code:
The Code is as follows:
Function person (name, age ){This. name = name;Th
A detailed explanation of the principles of the Javascript prototype chain and a detailed explanation of the javascript prototype chain
This article analyzes the principles of the Javascript prototype chain. We will share this with you for your reference. The details are as follows:
I. JavaScript prototype chain
ECMASc
As mentioned in the article on JavaScript creation objects: One problem with creating objects with constructors is that the same method for different instances of the same constructor is not the same, so we use prototypes to extract the public properties and methods of the constructor for encapsulation. Achieve the purpose of having all instances shared.Next you'll learn more about JavaScript prototypes.First, JavaScript prototype mechanism 1, the rel
When using object-oriented programming, the inheritance relationships between objects are indispensable! Prototype is an important method to implement javascript inheritance!Let's take a look at the following code:Copy codeThe Code is as follows:Function person (name, age ){This. name = name;This. age = age;}Person. prototype. getInfo = function (){Alert ("My name is" + this. name + ", and I have" + this. a
First, prototype (Prototype) mode
The purpose of the prototype pattern is to specify the type of object to be created by giving a prototype object, and then create more objects of the same type with the method of copying the prototype object.
From the means of Sun Dasan
T
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.