Inheritance of Properties and Methods through the Prototype Object Chain
This chapter provides introductions and tutorial examples on object property and method inheritance. Topics include inheriting properties and methods from constructor's prototype; reviewing built-in default properties and methods; using the 'constructor' property; adding local and inherited properties; overriding inherited properties.
These sections are omitted from this Web preview version. To view the full content,
see information on how to obtain the full version this book.
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
- When defining a constructor function, you are actually defining a
- When creating a new object by calling the constructor function,
you are inheriting properties and methods from the prototype defined
in the constructor.
- You can modify the prototype of a constructor at any time.
- An object inherits properties and methods from its prototype,
and the parent prototype of the prototype, and so on.
- The root prototype has some built-in properties and methods: constructor,
hasOwnProperty(), isPrototypeOf(), toString() and valueOf().
- Properties and methods can be added locally to individual object instances.
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
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications
Full Version in PDF/EPUB