• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 3. JavaScript in Action > Objects, Methods, … and Even Properties

Objects, Methods, … and Even Properties

One thing you've probably heard about JavaScript is that it is an object- oriented language. But what does this really mean? To understand this, you need to be familiar with three terms:

  • Objects

  • Methods

  • Properties

What follows is a brief look at the three. After you have used JavaScript for a little while, you'll find yourself using them a lot more, so we can leave the detailing of them until later.


Put simply, an object is a thing, anything. Just as things in the real world are objects (cars, dogs, dollar bills, and so on), things in the computer world are regarded as objects, too.

To JavaScript, its objects all live in the Web browser. These are things like the browser window itself, forms, and parts of forms such as buttons and text boxes. JavaScript also has its own group of intrinsic, or built-in, objects as well, which relate to things such as arrays, dates, and so on. At the moment, you don't need to think too much about these objects because they'll be covered later; for now you just need to get some of the necessary terminology in place.

But it is objects that make JavaScript object-oriented. JavaScript is organized around objects rather than actions; to put it another way, it's organized around data rather than the logic of the programming. Object-oriented programming takes the viewpoint that what you really care about are the objects you want manipulated and not the logic required to manipulate them. One of the benefits of this is that—because you are freed from the logic of the programming—not only is the process of programming (or scripting) easier, but there are also many ways to perform a particular operation.


Methods are things that objects can do. In the real world, objects have methods. Cars move, dogs bark, dollars buy, and so on. alert() is a method of the Window object, so the Window object can alert the user with a message box. Examples of other methods are that windows can be opened or closed and buttons clicked. The three methods here are open(), close(), and click(). Note the parentheses. Look out for these because they signal that methods are being used, as opposed to properties.


All objects have properties. Cars have wheels and dogs have fur. For JavaScript, things such as the browser have a name and version number.


It might help you to think of objects and properties as things and methods as actions.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint