JavaScript

Tuesday April 8, 2025
updated: April 10, 2002

 
Home
Getting Started
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Resources
Credits

 

 


Lesson 5: Object's Properties and Methods

Object

An object is a collection of data that includes the properties, other objects, and associated function (methods) of the object. Your web page is an example of an object. Any table, image, button or form is also an object. In the Java statement from lesson 1 below, document is the object.

document.writeln ('This text is written with Java code<br>');

PROPERTIES

Each object has certain properties. When you change the details about something which already exists you are changing its properties. For example the background color of your document is written: document.bgcolor. To change your background to the color red you would write the line: document.bgcolor="red".

METHODS

Whenever you need to DO something,  like write text to the screen in lesson 1, you are using a method. Most objects have a certain collection of things they can do. Just as a a door can open or close, different objects can do different things. A new document is opened with the method document.open(). You can write "Java is Fun" into a document by typing document.write("JavaScript is Fun") In these examples open() and write() are both methods of the object: document.

Some other important JavaScript objects include: String Object, Array Object, Date Object, Math Object, Window Object, Frame Object, Form Object
Browser Object. For more information on these goto: http://www.w3schools.com/js/default.asp


© 2002 Tracy Johnson