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 trialMax van den Berge
6,506 PointsAt the end of an Object Literal is a semi colan. var name = {} ;. My question is, why is there a ; . is it like a to cal
hi i have 2 questions :)
At the end of an Object Literal is a semi colan. var name = {} ;. My question is, why is there a ; . is it like a to call / invoke it?
is the following description of an Object literal also correct?
OBJECT LITERAL is an “own” created object , where you can store all sorts of related information that you want. (this is called encapsulation of information, or grouping information)
var name = {name : Ross
};
In this new/ “own” created object you now can store information in a key value.
The key is the objects name,
and an you can add a value to it.
For instance name(key) : Ross
(value) this is a key value pair or the object property. And this is now a part of this object.
love to hear your response :) greeting, Max
2 Answers
Steven Parker
231,271 Points- The semicolon is the standard ending for any JavaScript statement, it's not specific to the object literal.
- Where did you see this description? The key does not have to be (or include) the object name. Objects consist of properties, and the key is also known as the propery name.
Max van den Berge
6,506 Pointsthanks for your replay.
Im wrote this description myself. I could not find a clear discription of it. For me was not clear how an Object Literal is different from an object, so i created this description myself.
Steven Parker
231,271 PointsThe only difference is in how they are created.