Understanding JavaScript objects – Online JavaScript help

Understanding JavaScript objects – Online JavaScript help cover image
  1. Home
  2. JavaScript
  3. Understanding JavaScript objects – Online JavaScript help

Okay, so we learnt that JavaScript uses a hierarchical dot notation to refer to objects. In addition to the name property, objects can have other properties.
For example, an image located in a document is an object and has the following properties:

To refer to the source of an image named logo we use:

document.logo.src

Similarly, its width is refered as:

document.logo.width

Different HTML elements have different properties. For example, a text field form object has the following properties:

To set the value of a text field, we use the = (equal too) operator as:

document.contactform.add.value = "Type your address here";

This is a JavaScript statement that instructs the browser to displays the text Type your address here in the text field add.

JavaScript