oojs : 2. Accessing Object’s Properties

Accessing Object’s Properties

There are two ways to access a property of an object:

  • Using square bracket notation, for example person[‘first_name’]
  • Using the dot notation, for example person.first_name

Let’s take this object student:

		var student={
				name:'suresh kumar',
				ID: '1214',

		Accessing a property(name) of an object student using the dot notation:

		student.name;  // results in Suresh kumar
		Accessing a property(name) of an object student using the bracket notation:

		student[name];  // results in Suresh kumar


Let’s now take a look at object within an object or nested object

	var employee={
    firstname:'suresh kumar',
    designation:'tech lead',

employee.projects.firstProj; // results in angularJs

In the above example we created a employee object and within employee object we have one more
object “projects” which holds first and second proj properties.

To access firstProj value we have to use employee.projects.firstProj


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 *