Javascript language essence and programming practices-prototype inheritance notes

Source: Internet
Author: User

1. Direct Volume: the value of direct volume can be confirmed at the same time of declaration; undefined, true/false, String, value, regular expression, null

2. expression: the syntax structure of the result generated by operators and operators, which is unpredictable;

A statement is a sentence or command separated by ";". If a ";" is added after an expression, it indicates that "only an expression exists, statements without other syntax elements ";

Single-value expression: Expressions without operators are called Single-value expressions;

3. null is an empty object. You can use for in for enumeration, but the enumeration is not empty. Because it is not from the object () constructor (or subclass) instance, instanceof returns false;

4. {} is an empty object. It has all the features of the object and predefined attributes and methods, because it is an instance of the object () constructor (or subclass, therefore, instanceof returns true. You can use for in for enumeration. Some operations can enable empty objects to enumerate some attribute names.

5. the object has no prototype. Only the constructor has the prototype and attribute 'constructor. prototype' points to the prototype. The object only has the question of "constructing a prototype" and does not have the question of "Holding (or having) a prototype ".

6. A prototype is actually an object instance. An empty object is the basis of all objects. The object construction process can be simply mapped to an 'replicase' empty object. Javascript uses "copying member information to the instance image only when a member of an instance is written".

This means that all instances are directed to the prototype. When operating the instance, you can follow the pointer to find some properties and methods in the prototype. However, when a member of the instance is different, copy the member information to the instance image;

7. Object Construction Process:

A function has a prototype member, but it has no value at all during function initialization. The constructor features only when the prototype is referenced, in addition, the function prototype is always an instance of the standard and built-in object () constructor. However, after the instance is created, the constructor attribute is always assigned to the current function.

8. An object instance is essentially "A structure pointing to its prototype and holding an attribute list", all of which are inherited from object. prototype.

9. Basic Properties of the object prototype include:

Basic Properties of object prototype
Member name Type Category
Tostring Function Dynamic Language
Tolocalestring Function
Valueof Function
Constructor Function Object System: Construction
Propertyisenumerable Function Object System: Properties
Hasownproperty Function
Isprototypeof Function Object System: Prototype
Special Member of the constructor (function)
Member name Type Functional Language
Call Function
Apply Function
Caller Function
Bind Function
Arguments Object Dynamic Language
Length Number
Prototype Object Object System: Prototype

10. Each instance has a proto attribute. This attribute points to the prototype and is called the "Internal prototype chain". Therefore, an instance has two prototype chains.

11. For an instance generated by a constructor, its constructor attribute points to this constructor by default.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.