1. How to accurately determine if a variable is an array type2. Write an example of a prototype chain inheritance3. Describe the process of a new object
Knowledge Point #####
constructor function
function Foo (name,age) { this.name=name this.age=age this.class= ' class-1 ' //return this // The default is this line}var f=new foo (' Zhangsan ',//var f1=new foo (' Lisi ', 22)//Create multiple objects
Constructors-
In JavaScript play inheritance (II), I used the prototype inheritance method to implement JavaScript inheritance. What is the mysteries of prototype. In this articleArticleI will discuss the prototype.
Aside from JavaScript, Let's first look at the common object-oriented language we are familiar. Among the 23 design patterns, you will surely remember that there
Definition
The prototype mode specifies the types of objects to be created, and creates new objects by copying these prototypes. The prototype mode allows an object to create another custom object without any details. Working principle: by passing a prototype object to the object to be created, the object to be created will be executed by requesting the
Design Patterns ----Prototype ( prototype ) Mode
GoF : Specifies the type of object to create with a prototype instance, and creates a new object by copying the prototypes.
Using Java Collections For example, ArrayList, HashMap, and so on must have had the experience of copy an object to another object, with the Clone () method probably used.
// The above code is equivalent to 3 var p1 = {}; 4 person.apply (P1, [' Mikej ']);The constructor pattern looks good, but one drawback is that it wastes memory, and then the example// falseTo avoid this flaw, but using prototype mode to create objects, each object in JS has a prototype attribute to point to another object, and all properties and methods of that object are inherited by the instance of the
Primary role in prototype mode
Abstract prototype (Prototype) role: Declares a clone of its own interfaceSpecific prototype (concrete Prototype) role: Implementing a clone of its own operation
When a class is mostly the same and only part of it is different, it's expensive
DOM note (12): Prototype object and dom prototype
Because I have previously paid a note on the prototype object: Let's talk about the prototype mode in JavaScript. Now I can see this topic again and have a better understanding of the prototype. So I have to talk about the
prototype is a more difficult to understand the concept of JavaScript, the prototype related to more properties, the object has "prototype" attribute, the function object has "prototype" attribute, the prototype object has "constructor" attribute.
First, the initial knowled
JS prototype chain details and sample code, js prototype sample code
Preface
On segmentfault, you can see the following question:
var F = function(){};Object.prototype.a = function(){};Function.prototype.b = function(){};var f = new F();
Q: Can I obtain a and B from f? What is the principle?
At first glance, it was a bit difficult. I studied it carefully and found that I still did not understand the
Php design mode Prototype (Prototype) code. Copy the code as follows :? Php ** prototype ** specifies the object type to create with the prototype instance, and creates a new object by copying the prototype ** abstractclassPrototype
The code is as follows:
/***
Five prototype tools most suitable for UX designers and five prototype tools for ux designers
UX designers design products based on user experience. Their task is to let users say "Yes ". The UX design involves various aspects of human-computer interaction, such as availability, functionality, interaction design, and information architecture design. Prototype too
In javascript, the shadow of Enumerable cannot be found at all, because the Prototype was referenced by the author from Ruby. In javascript, the shadow of Enumerable cannot be found at all, because the Prototype was referenced by the author from Ruby. In addition, Enumerable has no direct application opportunity in practice, and is mixed into other objects. It can be said that it is a "parent class" of othe
This article mainly introduces a misunderstanding of the Javascript prototype chain and prototype. If you need it, you can refer to my previous questions about prototype inheritance and identifier search in the Javascript prototype chain,
For example, the following code:
The Code is as follows:
Function Foo (){};Var
"_proto_ and Prototype"1.prototype (prototype function): The function has a prototype.prototype is an object that points to the reference address of the current constructor.2._proto_ (object's prototype object): All objects have _proto_ properties. When an object is instantiated with a constructor, the _proto_ property
This mind map is my summary of the object, prototype, prototype chain and other knowledge, the main reference elevation book sixth chapter, after writing to find so much, may be streamlined later. There may be errors in the content, and you are welcome to criticize. Download ==>githubECMAScript supports object-oriented (OO) programming, but does not use classes or interfaces. objects can be created and enha
The question to be resolved: Can we reduce the use of new, while avoiding the need for new objects, to understand the object's class name.
Train of thought: PHP5 provides a cloning method, we can add an object, and then each need to add and her similar objects, cloning he can be.
Prototype (Prototype) Pattern Example:
The code is as follows
Copy Code
Machine Soldier Class Cla
I. Object: Normal Object Function objectTwo. Constructor features: 1. A new instantiation is required, and the This object is used internally to point to the instance object 2 that is about to be generated. Uppercase letters, used to distinguish common functionsfunction Person (name) { the name=name}var person1=New person (' Xiaohong ') )var person2=New person (' Lili ')Person1.constructor=person constructor points to constructors, person's built-in properties Person.prototype (function objec
The intent of the prototype model is:
By giving a prototype object to indicate the type of object you want to create, you can then create more objects of the same type with the method of copying the prototype object.
This pattern has been implemented in the Java class Library, so long as you define a class that implements the Cloneable interface, objects create
If you want to understand the internal relationship between function and object, you must introduce another two concepts dominant prototype and stealth [[prototype]] Concepts1. Prototype: Each function object has a display prototype property that represents the prototype of
Although the prototype pattern is a pattern of creation, it has nothing to do with the engineering model, and the idea of the pattern is to copy and clone an object as a prototype, and create a new object similar to the original object. This summary will be explained by the copy of the object. In Java, the Copy object is implemented through clone (), and a prototype
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.