Sunday, November 14, 2010

Different ways to define javascript object

Creating objects using  new Object()


    var student = new Object();
    student.name           = 'John';
    student.rollNumber  = '12';

Creating objects using Literal Notation
     var student = {
                           name : "john",
                           rollNumber : "12"
                          }

No comments:

Post a Comment