Introduction to Javascript for Non-Nerds


What's an Object?

What's an Object?

Webster defines an Object as a focus of attention and action. So, what's that supposed to mean in terms of Javascript, you ask? Well, basically, an object is a thing on your web page that you can manipulate. An analogy would be what a noun is to a sentence. It is the receiver of action.

So, what are examples of objects? You browser window is a good example of an object. A radio button inside of a form could be an object as well. Your web browser's internal list of all the sites you have been to is also an object that you can manipulate. Basically, objects consist of what you put on a web page with your HTML code plus what is intrinsically available on your web browser.

So, why use objects? Well, the most important reason is for indentification. Imagine if you had just created an HTML file with a hundred forms, with each form having fifty radio buttons, and fifty checkboxes. Obviously, you would want a definitive method for organizing all the objects on the page. As a result, every object has a unique name. You assign the object its name when you create the HTML code using the name property. Here are some examples of HTML code:

<form name="joe"><input type="text" name="bob"></form>
<form name="myform"><input type="button" name="pushmebaby"></form>
So, how is this useful you ask? Well, now that we have named every object on the screen, we can access any of them by simply following the hierachial path to them. Another way to think of this is that we are giving all of the objects on the screen a mailing address. All of the objects live in a city called the document. In this city, there are many streets, one of which is a form called joe. And on this street, there is a text box called bob. So, when you write your final Javascript code, you will need to tell it the complete address of the object you are refering to. So, in our two examples above, the complete addresses of the objects would be:

document.joe.bob
document.myform.pushmebaby
As you can see above, every part of the "address" is separated by a period. So, using this convention, you can access any object from any place in your web page.

Okay, so now that we know what objects are and how to define them, what can we do with them? To understand this, we must look into properties.


HomeGo to Top Next Page