User-Defined Objects

Most of the objects discussed so far and those to be discussed in the rest of the book are defined in an HTML script. However, JavaScript provides a way that you can define your own objects with different properties. Each property can be assigned a value, just as with objects in HTML. The object constructor Object() is used to create user-defined objects using the following format:

						var userObj = new Object() 

After the object has been initialized, you can either add new objects to the existing object or add properties and their values. Consider an organization, the Acme Car Company, with the following five departments and two subdivisions:

Management

Research and Development

Finance

Production

Marketing

Sales

Fulfillment

To create ...

Get JavaScript Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.