JavaScript tutorial -2 Object creation

From now onwards we need to make our mind that we are learning JavaScript; comparing and learning a programming language may be a good idea for others language but this does not suite for JavaScript. This is because the way JavaScript is implemented is entirely different and it most time creates a confusion for learner when they try to compare with their natives programming languages.

In JavaScript everything is Objects. And to create object it is not necessary that we should have a class. Objects in JavaScript are class-free. This may sound wired but I told we are learning JavaScript and not other programming language. In JavaScript we can create object without a class.

As said early in everything is object i.e. arrays are objects, functions are object, regular expressions are objects.

There are many different ways to create objects. But one particular mechanism of creating an object could better and that is called object literals.

Object literals provide a very convenient notation for creating new object values.

Object literals have named values pairs. e.g.:


var myObj1 = {}
var myObj2 = {
name : "shakthydoss",
age: 24,
isInsane : false,
parent : {
father_name : "sekar",
mother_name : "lakshmi"
}
};

 

To continue the progressive learning: JavaScript tutorial -3 CRUD Operations with Object literals 


2 Comments

  1. Burton Haynes wrote
    at 12:13 PM - 17th September 2012 Permalink

    Hi ..

    your stuffs are interest and keep it up.

  2. coco chanel wrote
    at 5:06 PM - 1st November 2012 Permalink

    You made several good points there. I did a search on the theme and found the majority of persons will have the same opinion with your blog.

Post a Comment

Your email is never published nor shared. Required fields are marked *