Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialywang04
6,762 PointsIs Object mentioned in the "Native Objects in JavaScript" Object literal?
In this section, the teacher told us there are three kind of objects in JavaScript. One of them is Native Objects. The Native Objects include Number, String, Array, Boolean and Object.
I am not sure whether this mentioned Object is just the Object literal itself.
If it is, the Object literals are one common way to create objects, which is mentioned in the next video.
I am confused about Object and Object literal.
Any comments are welcome. :)
2 Answers
Dom Farnham
19,421 PointsHere are object literals:
var car = {};
var house = { windows: 4, doors: 1 };
It easier to create objects by using literal notation above as opposed to a constructor.
Here are examples of using a constructor:
var car = new Object;
var house = new Object;
house.windows = 4;
house.doors = 1;
Hope this helps. :-)
Dom Farnham
19,421 PointsNo problem. Shout if I can help with anything else. Please mark the question as answered.
ywang04
6,762 Pointsywang04
6,762 PointsThanks a lot. I mixed object up with object literal notation.....(: It's clear to me now.