Prototype is a JavaScript in the difficult to understand the contents of notes, the following through a few key points of knowledge to explain the prototype in JS. Please see the details below for specific content.
1 Prototype method design mode
You can use Clone () in. NET to implement the prototype method
The main
This article from: http://www.blogjava.net/heavensay/archive/2013/10/20/405440.htmlIntroduction of prototype, __PROTO__, Constructor, Object and function relations in JSAn Introduction to Prototype, __proto__ and object, function relationsfunction, Object:js functions object. Prototype, each function object has a display pro
The relationship between 1.__PROTO__ and prototypeThe __proto__ of all objects point to the prototype of their constructorsvar a = {"Test": ' Mico ', "Age": "};var" B = function () {};var c = new Date (); var d =/^[\d]$/;alert (a.__proto__ = object.pr Ototype); Truealert (b.__proto__ = = Function.prototype); Truealert (c.__proto__ = = Date.prototype); Truealert (d.__proto__ = = Regexp.prototype); True Let's take a look at this piece of codeThe printe
Use a prototype instance to specify the type of the object to be created, and copy the prototype to create a new object.
The code is as follows:
/*** Prototype** Use a prototype instance to specify the object type and copy the prototype to create a new object.**/Abst
The prototype pattern is one of the creation patterns, which is characterized by the "copying" of an existing instance to return a new instance, rather than a new instance. The copied instance is what we call the "prototype", which is customizable.Prototype patterns are used to create complex or time-consuming instances, because, in this case, copying an existing instance makes the program run more efficien
Structure
Intention
Use the prototype instance to specify the kind of object to create and create a new object by copying the prototypes.
Applicability
When the class to instantiate is specified at run time, for example, by dynamic loading;
To avoid creating a factory class hierarchy that is parallel to the product class hierarchy;
When an instance of a class can have only one
Use a prototype instance to specify the type of the object to be created, and copy the prototype to create a new object.
Copy codeThe code is as follows:
/**
* Prototype
*
* Use a prototype instance to specify the object type and copy the prototype to create a new obj
When I first came into contact with this prototype I refused, I still spent a part of my time understanding this thing, not proficient, what questions to reply to belowAfter all, I was used to the bricks (funny);As I understand it, prototype is nothing more than a function of two foundations:1. Dynamically adding properties and methods of a class2. Copying the contents of the original classLet's take a look
Four. __proto__JS when creating an object (whether it is a normal object or a function object), there is a __proto__ built-in property called, which points to the prototype object that created its constructor.The object Person1 has a __proto__ property, and the constructor that creates it is person, and the prototype object of the constructor is Person.prototype, so:person1.__proto__ == Person.prototypePlea
===========================================
Objective
===========================================
Recently like MooTools (encounter AH), in the public expressed his preference. Many friends ask me why I want to love each other, in fact, the reason is quite a lot.
Here today I intend to enumerate some of them. Let more friends to understand MooTools, also hope to have more friends like him. The title of the article is doomed I will tell more about MooTools than
I. Common objects and Function objectsIn JavaScript, everything is Object! But the object is also different. is divided into ordinary objects and function objects, object, function is JS comes with the functions of the 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 (t
Prototype mode (PROTOTYPE)Defined:Prototype mode: Specifies the kind of object created with the prototype instance, and creates a new object by copying the prototypes. The copied instance is called a prototype, and the prototype is customizable.Prototype pattern is also a cr
Agreed to explain the JavaScript inheritance, but delayed to now explain. No more nonsense, go straight to the point.
Since you want to understand the inheritance, prove that you have a certain understanding of JavaScript-oriented objects, such as what you do not understand can refer to the object-oriented JS Basic explanation, Factory mode, constructor mode, prototype mode, mixed mode, dynamic prototype m
The Prototype design mode and prototype design mode can be used for clone replication.
Today we have a http://www.cnblogs.com/insus/p/4152773.html of Prototype, Prototype, a Prototype model. In order to enhance understanding and understanding, another exercise is now availa
Prototype source code analysis String section (1) about indexOf optimization. For more information, see. There are many methods added to String. prototype, but they are roughly divided into the following categories:
Category
Method Name
Original capability enhancement
Strip|Include|StartsWith|EndsWith|Empty|Blank
Format
Camelize | capitalize|Underscore|Dasherize|Inspect
prototype-1.4.0.js that comes with ajaxtags, to see how to encapsulate XMLHTTP objects into a reusable method.
8. ES6 New features Development applet (5)
Summary: ES6 adds a number of new APIs to native objects such as Object, Array, String, number, math, and so on. Object Object Object.prototype.proto: Objects have attribute proto, which can be called implicit primitive ...
9. Detailed description of how JavaScript implements OOP inheritance using
// The prototype method creates the object's properties and methods to achieve the purpose of sharing function Box () {}; // There 's nothing inside, if there is an instance property and method Box.prototype.name= ' Tianwei '; Box.prototype.age= ' + '; Box.prototype.run=function() { returnthis. name+ . Age;}; var box1=New Box ();d ocument.write (box1.name);Instance properties are not shared, prototype p
Note: The built-in function object Funtion prototype prototype is an instance of object , but it is a function type.Function. prototype instanceof Object; true ---is an instance of Objectfunction. prototype instanceof function ;// falsetypeof Function.prototype; the "function" ---is the function type.JS
At present is learning JS prototype thought (accurate from yesterday 2018.1.29 to formally contact), pondering two days, in the Chrome console constantly knocked a lot of code test __proto__ and prototype relationship, have a little harvest (see, as the saying goes, Specific things are easier to absorb than abstractions, so I draw a picture.Plot: Different color lines do not intersect, the same color line r
I. Common objects and Function objectsIn JavaScript, everything is Object! But the object is also different. is divided into ordinary objects and function objects, object, function is JS comes with the functions of the object.The following examples illustrate:functionF1 () {};varF2 =function(){}; varF3 =NewFunction (' str ', ' Console.log (str) '); varO3 =NewF1 ();varO1 = {}; varO2 =NewObject (); Console.log (typeofObject);//functionConsole.log (typeofFunction);//functionConsole.log (typeofO1);/
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.