Interpretation of Javascript Objects
Updated: November 24, 2008 21:39:31 Author:
ECMAScript does not have a regular class like C++, Smalltalk, or Java, but it supports creating objects and initializing all or part of the object's properties by executing code that allocates space.
All constructors are objects, not all objects are constructors. Each constructor has a Prototype property used to implement prototype inheritance and sharing properties. Objects are created by new expressions; for example, new String("A String") creates a String object. If the constructor is called directly through new, there will be a return value, and the type returned will depend on the constructor. For example, String("A String") produces a string of original type instead of an object.
ECMAScript supports prototype-based inheritance. Each constructor has a prototype associated with it, and the objects created through this constructor have an implicit reference (called a prototype of the object) 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 property, this reference points to the property named after the first object in the prototype chain. In other words, the first time, this directly associated object will be checked for this property. If this object contains an attribute named after this, this attribute is the attribute pointed to by reference. If this object does not contain attributes named, the prototype of this 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 which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects,but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance 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 an associated prototype, and every object created by that constructor has an implicit reference to the prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.
ECMAScript supports prototype-based inheritance. Each constructor has a prototype associated with it, and the objects created through this constructor have an implicit reference (called a prototype of the object) 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 property, this reference points to the property named after the first object in the prototype chain. In other words, the first time, this directly associated object will be checked for this property. If this object contains an attribute named after this, this attribute is the attribute pointed to by reference. If this object does not contain attributes named, the prototype of this 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 which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects,but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance 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 an associated prototype, and every object created by that constructor has an implicit reference to the prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.
Related Articles
Some views on javascript object prototype
Tips for JavaScript object prototype. Friends who are learning js object-oriented can refer to it.2010-09-09A brief discussion on object-oriented programming of Javascript
Javascript is a very flexible language that allows us to simulate many machine mechanisms in object-oriented programming.2011-11-11Three ways to change the pointer of this pointer inside a javascript function
The value of this javascript is really inexplicably amazing. I have been dizzy all the time. Maybe it is this that makes most people feel that js is very inexplicable.2010-04-04JavaScript writing method six
This article will start by analyzing the popular js library writing methods. Although the writing methods of various libraries are strange, they still cannot escape the essence - use constructors and prototypes to assemble classes.2009-07-07JavaScript copy object usage instructions
JavaScript copy object usage instructions, friends who need it can refer to it.2011-06-06JavaScript RegExp method gets address bar parameters (object-oriented)
I personally think that it is not a good thing to use more cycles. Here we recommend a method that uses OO ideas and RegExp to make it more flexible and efficient.2009-03-03constructor attribute after javascript new
Instructions for the use of the constructor attribute after new, friends who need it can refer to it.2010-08-08javascript object-oriented JavaScript class
This section will talk about the following concept - class. Although there is no class keyword in JavaScript, as developers, we must have this idea. In C#, classes can be divided into instance classes and static classes, and so does JavaScript.2010-05-05The core code required for writing your own js library
As we all know, using jQuery's extend method can easily implement inheritance and object copying. We can take it and use it ourselves.2012-07-07Object-oriented Javascript 2 (Introduction to interface implementation)
Interfaces are one of the most useful features in the object-oriented Javascript toolbox. We all know that GOF says in design mode: interface-oriented programming, not implementation-oriented programming2012-01-01