Js drag prototype declaration and usage summary, js drag prototype Declaration
The following is a self-written prototype declaration about js Drag and Drop: the code is as follows:
Notes:
1. Point this to who it actually points to
Analysis of JS prototype inheritance and class inheritance, analysis of js prototype inheritance
Let's first look at the inheritance of JS classes.
Let's look at the JS prototype inher
see from the running result of obj4 that this assignment method is to extend the original type rather than overwrite it.
Based on the above javascript creation type and extension using prototype attributes, We can briefly understand the implementation principle of prototype. js javascript framework. Prototype.
by person, meaning that "person.prototype" is part of the prototype chain of these instances, so when these instances are searched for attributes, they refer to the " Person.prototype the property in the.
How object creation affects prototype chains
var July = {
name: "John",
age:28,
getinfo:function () {
Console.log (this.name + "is" + This.age + "Years") Old ");
}
the Function.prototype object is Object.prototypeFunction.prototype.__proto__=object.prototypeAccording to this rule, Object.prototype is the final prototype of all objects.Learn the benefits of prototyping and prototyping chainsA new understanding of the properties and methods of the objects, the structure is clearer, so I can write a lot less repetitive codefun.__proto__ = Fun.prototypeobject. __proto__ = constructor that creates the object. protot
Simple second-level navigation menu prototype implemented by JS, and js navigation menu prototype
This article describes the prototype of simple level-2 navigation menu implemented by JS. Share it with you for your reference. The
: because if you want to add more properties and methods on the prototype object, we have to write a line person.prototype each time, rather than refining into an object directly. But this is a clever example of how to construct an instance object operation before adding a prototype method, which creates a problem:When var person = new Person () , Person.prototype is: Person{} (of course, there is also the
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 r
JS core series: Talking about prototype objects and prototype links in Javascript, all objects are objects, but there are also differences between objects, which can be roughly divided into two categories: common objects (objects) and Function objects (functions ).
In general, the objects generated through the new Function are Function objects, and other objects
First of all, the reference blog, thankHttp://blog.sina.com.cn/s/blog_6c62f4330102wq0u.htmlhttp://blog.csdn.net/leadn/article/details/51781539And so on, and there are some other links that don't stick here.JS in about prototype article many, today himself write a bit of their own understandingDo not like to come up on the sticky concept, because if the concept can understand, also do not need to write this article.about the
, that is, "Person.prototype" is part of these instances of the prototype chain, so when these instances for property lookup, it will refer to the " Person.prototype the properties in the.How object creation affects the prototype chain?
1 2 3 4 5 6 7 8
var July = { name: "张三", age: 28, getInfo: function(){ console.log(this.name + " is " + this.age + " years old"); }} console.log(July.getInf
Ultimate explanation of JS prototype and prototype chain
1. Common objects and function objectsIn JavaScript, everything is an object! But there are also differences between objects. It can be divided into common objects and Function objects. Objects and functions are built-in Function objects of JS. The following is a
First, prototype and __proto__1, prototype (explicit prototype): Each function will have a property named prototype after it is created, which points to the prototype object of the function. It exists only in functions, such as the following example: function person (name)
About prototype and prototype attributes and common methods in js, jsprototype
Prototype is a hard part of javascript notes. The following describes prototype in javascript through several key knowledge points. For details, see the following.
1 original method design mode
In
three objects are created by the new function ().
There are two ways to create objects in JavaScript: Object literals and the use of new expressions, the creation of O1 and O2 corresponds to the two ways, focusing on the O3, if understood in Java and C #, O3 is the F1 instance object, O3 and F1 are the same type, At least I used to think so.
So how do you understand it? It's easy to see if O3 is created by the new function, obviously not, since it's not a function object, it's a normal object
Console.log in the prototype chain (A.MARK2); "A2_changed" Console.log (A2.MARK2); "A2"Why a can make the ChangeMark2 method in the prototype? This is related to JS Ingenious prototype chain, in Firefox we can print out the object and can see the object below the __proto__.We use the above process to represent the fl
.
// 函数表达式 var func; if(true) { func = function () { console.log("f1()--1"); }; } else { func = function () { console.log("f1()--2"); }; } func();
function expressions, the output is F1 ()--1. So use function expressions as much as possible.
2. Strict modefunction func() {
Under normal circumstances, the evidence is correct.
"use strict";function func() { console.log(this) // window}window.func()
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.
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.
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.