Object

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email
An object is a software model typically used to represent a real world object along with a set of behaviours or circumstances. In JavaScript, built in objects can also represent the structure, action, and state of an HTML page. In Object Oriented Terminology, the actions are called as methods, and states are called as properties.

To build an object you must know something it. Let us take a squirrel as an example. A squirrel has several physical properties, including gender, age, size, and colour. It also has properties relating to its activities, such as running, jumping, eating peanuts. It's methods relate to change in behaviour or state, such as run away, stop and look or chatter.

Creation of an object involves two steps:

1. defining functions that outlines the object
2. creating an instance of that object
Let us now create a JavaScript squirrel :

<SCRIPT Ianguage= "javascript">

function squirrel(color)
{
this. color= color;
}
var groundSquirrel = new squirrel("blue") ")I¬
//--->
</SCRIPT>

The first part of the script with the function tag outlines the in itial state for any given squirrel. It accepts one parameter, called color, that becomes a parameter. By itself the function does nothing it must be invoked and assigned to a variable. That is why we created an object called groundSquirrel with the blue colour ' The color is accessed by joining the object name with the property name: groundSquirrel.color



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.