![]() |
Objects, Methods and Properties![]() ![]() ![]() ![]() ![]()
An object is a "package" of data; a collection of properties (variables) and methods (functions) all classed under a single name. For example, imagine that there is an object named car. We could say that the car object possesses several properties: make, model, year, and color, for example: We might even say that car possesses some methods: go(), slop(), and reverse(). Although the car is obviously fictional, you can see that its properties and methods all relate to a common theme.
In JavaScript you may create your own objects for storing data. More commonly, though, you will use the many "built in" objects, which allow you to work with, manipulate, and access the Web page and Web browser. This set of pre existing objects is known as the "Document Object Model"(DOM). Document Object Model Often referred to as the DOM, this object model is a hierarchy of all objects "built in" to JavaScript. Most of these objects are directly related to characteristics of the Web page or browser. The reason we qualify the term "built in " is because the DOM is technically separate from JavaScript itself. That is, the JavaScript language specification, standardized by the ECMA(European Computer Manufacturers Association), does not actually specify the nature or specifics of the DOM. Consequently, Netscape and Microsoft have developed their own individual DOM's which are not entirely compatible. Access the properties of an object with a simple notation: objectName.propertyName. Both the object name and property name are case sensitive, so Watch your typing. Because a property is essentially a variable, you can create new properties by simple . assigning it a value. Assuming, for instance, that carObj already exists (we'll learn, to create a new object shortly), you can give it properties named make, model, and year as follows:
carObj.make= " Maruthi'
|
|
Domain NamesJAVASCRIPT Types of Variables Arrays Data Type Conversion Arithmetic Operators Logical and Comparison Operators Assignment Operators Ternary Operators Operator Precedence Assignment Statements If StatementsSwitch Statement Function Call Statement Try, Catch and Throw Statements The For Loop Java While Loop The Do While Loop Break and Continue Statements
String Methods Array Methods Objects, Methods and Properties The Boolean Object The Date Object The Global Object The Math Object
The Number Object Color Constants Hierarchy of Browser Objects Window Object Document Object History Object Navigator Object Buttons Check Box Radio Buttons Text FieldsWorking with Image Maps Creating Simple Animation Hidden Fields Working with Style Sheets An Example of HTML Graphics Replacement The <SPAN> Tag Positioning of HTML Content The <LAYER> TagWeb DesignWeb HostingE Commerce |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |