Objects in JavaScript


Objects are like black-boxes. Once they are done they should be self-sufficient and self-supporting. Independant of each other. Objects have properties like color for instance. Those properties can have values like blue or red. Objects also have methods. Methods are like functions. However, methods act on the object alone to produce some desired result. A method is exclusive to a specific object. Like changing the color of our red colored object from red to blue. The method could be called colorChangeFromRedtoBlue(); and acts on our object called Ball. Thus the method would be executed as Ball.colorChangeFromRedtoBlue().

JavaScript supports three types of objects.

  1. Built-in objects are objects which are built into the JavaScript language.

  2. Browser objects are objects which represent components of the browser.

  3. Custom objects are objects created by the author of a web page.