JavaScript Object-Oriented Programming

An Object

An object is a collection of properties. These properties can either be primitive data types, other objects, or functions (which in this case are called methods, but more on this later).

A constructor function (or simply, constructor) is a function used to create an object - this too we'll discuss in detail later. JavaScript comes with many built-in objects, such as the Array, Image, and Date objects. Many of you are familiar with Image objects from creating those ever-so-cute rollover effects.

Pre defined objects

Javascript has many built-in objects, such as the Array, Image, and Date object.

New objects

Using this code you have in fact created a new Image object, and assigned a property of your new Image object

the src property. Image1 is a new Image object; in other words, it is an instance of the Image object.

Using JavaScript's dot-structure ( . ), the code above then accesses and sets the src property of your new Image object.