Codes for Assignment Creating a new object


#1

Hi, can anybody help me about these codes? Not sure if I did it wrong. Thanks!
var me=new Object(){
me.name="Beichen";
me.age=24;
}


#2

What you have here is a combined constructor and literal which is invalid. Use one of either constructor notation (dot) or literal notation (object literal), but not both.

var me = new Object();
me.name = "Beichen";
me.age = 24;

or

 var me = {
    name: "Beichen",
    age: 24
}

Note the subtle differences in syntax.


#3

please someone help me out here
my code is :
var me = new object();
me.name = "Amir";
me.age = 25;

i dont know exactly what is wrong with that !


#4

When we use the new operator it is to invoke a new instance of a class. By convention, classes always start with a capital letter. This will come up shortly. For now though, just remember that Object is a class, so gets the capital.

var me = new Object();