Defining Your Own Object Types
This chapter provides introductions and tutorial examples on how to define your own object types. Topics include defining constructor functions; adding properties and methods to objects or constructor prototypes; looping through properties and methods; using 'instanceof' and 'typeof' operators.
Prototype-Dased Object-Oriented Programming Style
Defining Object Constructor Functions
Adding Properties and Methods to Objects
"for ... in" and "for each ... in" Statements
"prototype" Property of the Constructor Function Object
"instanceof" Operator - Determining Object Type
"typeof" Operator and Data Types
object encapsulation, polymorphism, and inheritance.
- Objects are created by calling constructor functions: New Abc().
- Object properties and methods can be added in the constructor function.
- Object properties and methods can be added to individual instances too.
- "for (var item in object_name)" and "for each (var value in object_name)"
statements can be used to loop through properties and methods in an object.
- A constructor function itself is an object, which has property called
"prototype" referring the prototype definition.
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