Prototype Object Chain Summary
This section provides a quick summary of object property and method inheritance through the prototype object chain.
Here is a summary of how object, constructor, and prototype are related to each other.
- An object is created from a constructor function, which is also an object.
- A property can be added to an object through the constructor during the object creation process.
- A property can be added to an object after it has been created.
- A constructor contains a property called "prototype", which points to an object serving as the prototype
to the constructor.
- An object inherits all properties of its constructor's prototype.
- The inheritance process is recursive process, which allows an object to inherit from multiple levels of prototypes of its constructor prototype chain.
- The prototype of the constructor "Object" is base prototype of any prototype chain.
- Methods follow same inheritance rules as properties. Actually, methods are properties with function definitions as their values.
- The base prototype has several built-in default properties and methods.
Here is my diagram representing relations of object, constructor, and prototype.
It also shows how object properties and methods are inherited from its parent prototypes:
Table of Contents
About This Book
Data Types, Variables and Expressions
Flow Control Statements
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
Server-Side and Client-Side Web Scripting
Introduction to Objects
Defining Your Own Object Types
►Inheritance of Properties and Methods through the Prototype Object Chain
Inheriting from Constructor's Prototype Object
Changing the Constructor's Prototype Object
Inheriting Properties from Two Level Prototype Objects
Built-in Properties and Methods in "Object.prototype"
Using "hasOwnProperty()" Method to Test Inherited Properties
Setting the "constructor" Property in the "prototype" Object
Adding Local Methods at the Object Level
Adding Inherited Methods at the Prototype Level
Building Multiple Levels of Prototype Objects
►Prototype Object Chain Summary
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications
PDF Printing Version