Objects provide us with a way to represent real-world or virtual things. We can do this by storing information inside the object's properties. There are two basic ways to make objects:
Literal Notation, where we use
var Name = { };
Constructor Notation, where we use the keyword new.
We've given an example in literal notation to refresh your memory.
Instructions
Make a new object,
spencer2
, with the same properties but using constructor notation and the Object
constructor.
var spencer = {
age: 22,
country: "United States"
};
var spencer2 = new Object();
spencer2.age= 22;
spencer2.country= "United States";
No comments:
Post a Comment