Object oriented javascript | oojs in easy steps

Introduction: Arrays v/s objects

Before we start of with Objects in Javascript, I think most of us are familar with Arrays

Lets consider an array browser


each value has an index that is on browser[0] we get firefox


An object is very similar to an array but with the difference that you define the keys yourself. You’re not limited to using only numeric indexes but can use friendlier keys, such as first_name, age, and so on.

Let’s take a look at a simple object and examine its parts

			var person={
				topic:'object oriented javascript'


You can see that:

  • The name of the variable that contains the object is person
  • Instead of [ and ] which you use to define an array, you use { and }
    for objects
  • You separate the elements (called properties) contained in the object
    with commas
  • The key/value pairs are divided by colons, as key: value

In the next post we will see how to Accessing Object’s Properties


I Am suresh(suresh kumar )a Web developer,Freelancer,webdesigner,UI developer from bangalore. Got 6+ yrs of IT experience . I specialize in standards-based XHTML, CSS and JavaScript web development. Each site I develop is built to be search engine friendly (SEO), using the latest development principles and techniques.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *