Javascript advanced-prototype, prototype
I. Understanding of javascript prototype
Many programming languages have the concept of classes. We can compare prototypes and classes to see the differences and similarities between them.
1. Class: class is the abstraction of a specific thing, so class is an abstract thing. In object-oriented mode, classes can be used to
The previous article tells the prototype concept of js, and here is a review of the definition of prototype:Prototype is a property of a function and is a prototype object of a Function. It is necessary to refer to the function, which should be remembered.but, It's strange, crossing, have you ever seen a JS code that references prototype like This:function func (
7.6 prototype mode Summary
Prototype is a method for quickly creating a large number of identical or similar objects. It is widely used in software development. Many software products provide copy (CTRL + C) and paste (CTRL + V) the operation is a typical application of the prototype mode. The following briefly summarizes the effects and applicability of the mode
Analysis of Principles and Examples of javascript prototype, prototype chain, and object replication (II)
PrototypePrototype is an important concept in JavaScript object-oriented features and is also a concept that everyone is too familiar. Because in most casesIn the object-oriented language of data, objects are class-based (such as Java and C ++), and objects are the results of class instantiation. InTher
The prototype mode in JavaScript and the prototype in javascript
Objects Created in JavaScript are created in many ways, such as factory mode, constructor mode, and prototype mode:
Its Equivalent prototype:
function Person(){}Person.prototype = {name:"dw",age:20,job:"IT",sayName:function(){alert(this.name);}};var
The relationship between prototype and _ proto _ in Javascript is described in detail. prototype _ proto _
Preface
When I learned the prototype, I felt my head was too big )/~~ In particular, prototype and _ proto _ are too stupid to find out more information. Based on your understanding, the following is a summary:
1.
/* Source author: stone not Easy (Louisshi) contact information: http://www.shibuyi.net============================================= ====================================================== Program name:javascript Package Library Prototype version Iteration : non-functional total:14 features:1. implementation code concatenating 2.id/name/tagname/ class node Get 3.class selector Add with remove 4.css rule Add and remove 5. set with Get element inner text
The prototype property can add properties and methods to any object (number, Boolean, String, date, and so on).
Note: The prototype (PROTOTYPE) is a global property that can be used in almost all objects.Grammar
Object.prototype.name = value
Instance:
Here's an example of how to use the properties of a protot
a great extension of JavaScript and a good support for Ajax, as well as a library of effects based on such libraries at home and abroad. Prototype.js is not only a great practical value of the JS library, but also has a high learning value. --in Prototype.js, prototype object is an important mechanism to realize object-oriented. Each function is an object (function) that has a child object prototype ob
Copy code code as follows:
/**
* Prototype Mode
*
* Use a prototype instance to specify the kind of object to create. And by copying this prototype to create a new pair of Like
*
*/
Abstract class Prototype
{
Private $_id = null;
Public Function __construct ($id)
{
In JavaScript, this is defined when created. What does this sentence mean?
function Foo () {
this.name = ' Peter ';
}
Foo ();
Console.log (name);//this is the global object when it is created, so the name here is Peter;
So what's different about adding a keyword new?
Let's say varobj = new Foo ();
In JavaScript, the new keyword does three things:
First, generate a new object
One, Varo = {}; Generate an Empty object o
Second, o.__proto__= foo.prototype;//the
0. The motive of this articleUsing a time of LUA, used to Java C + + and other classes have the Class keyword language, has been to Lua's object-oriented technology is puzzling, an open source of the Objectlua is to see n times also did not understand the principle, until see prototype-based ProgrammingI. What is prototype-based programming Prototype-based progr
This article mainly introduces the object-oriented JS basic explanation, Factory mode, structural function mode, prototype mode, mixed mode, dynamic prototype mode, the need for friends can refer to the nextWhat is object-oriented? Object oriented is an idea! (nonsense).Object-oriented can treat the key modules in the program as objects, while the modules have properties and methods. This way, if we encapsu
Recently I learned nothing about what I think, and the progress is not obvious. So I occasionally look at the prototype source code and take notes for analysis.
I remember that when I used to look at jquery's source code, I searched the internet and analyzed a bunch of source code. However, most of them can only be regarded as comments. I am a beginner like me.
So now, jquery's source code only looks at the first few hundred lines. Select
Prototype: When a function is created, the function itself has some attribute methods, one of which is prototype, which is the prototype.All functions have the original type.The prototype solves performance problems.The prototype of the constructor. Only its instantiated objects can be used.All objects have _ PROTO _ (
This article address: http://www.cnblogs.com/archimedes/p/java-prototype-pattern.html, reprint please indicate source address.Prototype modeUse the prototype instance to specify the kind of object to create and create a new object by copying the prototypes.OverviewThe prototype pattern is a mature pattern of starting from an object with a new object of its own st
When using object-oriented programming, the inheritance between objects is naturally unavoidable! And the prototype is a very important way to achieve JavaScript inheritance!
Let's start by looking at the following code:
Copy Code code 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.age+ "years old");
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
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
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.