Javascript Objects

An object is collection of data, which describes the properties (variables) and methods (functions) of the object. Let's make a car the object of this example. A car has several properties: color, year, model, and make. A car also has many functions: accelerate(), brake(), and reverse().

In the programs you write, you may create any kind and as many objects you wish. JavaScript has many built-in objects that we can use and the hierarchy of these objects is known as the Document Object Model (DOM). The DOM can be used to manipulate your web page and web browser.



properties

When you want to access a property of an object, use the format example below.

car.color = "red"; car.year = "2000"; car.model = "Bonneville"; car.make = "Pontiac";

methods

When you want to execute a function of an object, use the example below.

car.accelerate(); car.brake(); car.reverse();

Intro         • Variables         • Statements         • If then else

Loops         • Objects         • Functions

Home   |   Business Directory   |   Festivals and Fairs (USA)