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 trial

JavaScript Object-Oriented JavaScript (2015) Introduction to Methods Different Kinds of Objects

ywang04
ywang04
6,762 Points

Is 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
Dom Farnham
19,421 Points

Here 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. :-)

ywang04
ywang04
6,762 Points

Thanks a lot. I mixed object up with object literal notation.....(: It's clear to me now.

Dom Farnham
Dom Farnham
19,421 Points

No problem. Shout if I can help with anything else. Please mark the question as answered.