Interpretation of Javascript objects _js object oriented

Source: Internet
Author: User
All constructors are objects, not all objects are constructors. Each constructor has a prototype property that implements the prototype inheritance and shared properties. object is created with a new expression, for example, new string ("a string") creates a string object. A direct call to a constructor without a new one will have a return value, and the returned type will depend on the constructor. For example, String ("A string") produces a string of the original type rather than an object.
ECMAScript supports prototype based inheritance. Each constructor has a prototype associated with it, and objects created through this constructor have an implicit reference (called an object's prototype) associated with the constructor prototype. Further, a prototype may have a non-empty implicit reference to its prototype ..., which is called the prototype chain. When a reference points to an object's properties, this reference points to the attribute in this name of the first object in the prototype chain. In other words, for the first time, this directly associated object will be checked for this property. If this object contains an attribute with this name, this property is the attribute that the reference points to. If this object does not contain an attribute with this name, then the prototype of the object will continue to be checked ...
Original:
Object
ECMAScript does not contain proper classes such as those in C + +, Smalltalk, or Java, but rather,supports, constructors whic H Create objects by executing code this allocates storage for the objects and initialises all or a them by assigning Initial values to their properties. All constructors are Objects,but is not all objects are constructors. Each constructor has a Prototype property, is used to implement prototype-based and shared properties. Objects are created by using constructors in new expressions; For example, new string ("a string") creates A new string object. Invoking a constructor without using new has consequences that depend on the constructor. For Example,string (' a String ') produces a primitive string, not ' an object.
ECMAScript supports prototype-based inheritance. Every Constructor has a associated prototype, and Every object created by that constructor has a implicit reference to T He prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to it prototype, and so on; This is called the prototype chain. When a reference was made to a, the "reference is" to the " The prototype chain that contains a property of that name. In the other words, the ' object mentioned directly is examined to such a property; If this object contains the named property, that's the property to which the reference refers; If this object does not contain the named property, the prototype for this object is examined next; And so on.

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.