Creating a new object


#1



Replace this line with your code.


#2

var myObj = new Object();
var myObj{

myObj["name"] = "Anouk";
myObj["age"] = 17;
};

var myObj{};


#3

HI you can create an object in two way

var object1 = new Object();
object1.name = "Fred";
object1["age"] = 10;


or

var object1 = {
   name: "fred",
   age: 10,
}

#4

var me = new Object(); {
me["name"]="Glau";
me.age=36;
};


#5

var object1 = new Object();
object1.name = "Fred";
object["age"] = 10;

this code is error.when you run this code it says object not defined.
object1["age"]=10; this line ok.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.