Lesson 3: Objects

An object presents something. It may be anything ranging from an a text field where you input information, a button, or even your whole document. Outside the realm of JavaScript you use objects all the time when you use a paint program or a word processor. If you want to justify a paragraph in a word processor all you have to do is press the justify button on the tool bar. That button is an example of an object.

All objects have properties. For example a pencil has a shape, diameter, color, weight and any other features. When you create objects in JavaScript you also have to define its properties.

The last thing you should know about JavaScript is something called METHOD ACTORS. Method actors are simply a series of steps that tell an object what to do. For example in LESSON 1, you used a method to write what version and name of the browser you are using as a visitor:

document.write ("This browser is version "+ navigator.appVersion)

The .write ( ) command is actually a method that requires a parameter string to tell it what to write. Don't get confused about the terminology here, soon you will pick it up because you will see that it is very logical. In summary, methods simply define the behavior of objects by providing steps that an object should follow. If the properties of an object define what the object is going to look like, the method tells it what to do.

You may have already realized that you have already created an object, defined its properties, and provided a method actor in LESSON 2 when you created the alert box.

Your next lesson will explain why JavaScript is object-based rather than object-oriented. We will explain in LESSON 4.