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 trialDennis Fayard
7,567 PointsNot sure I understand what they mean by an object literal score : 0, playerName: "Dave", spaceShi
Not sure I understand what they mean by an object literal
2 Answers
Jennifer Nordell
Treehouse TeacherHi! An object literal is simply a set of name and value pairs wrapped in curly braces. To expand on the example you're looking at I made this object literal.
var player = {
name: 'Jennifer',
score: 0,
highScore: 200,
level: 2,
isAlive: true
}
The name is the word before the colon and the value comes after the colon and can really be any data type at all. Hope that helps!
jason chan
31,009 PointsAn object lateral is basically an object. An object is representation of things in the world.
player will have properties of the following. name, score, highScore, level, and boolean.
Object laterals are used to store data and prevent things from colliding overwritten. Also known as a namespace.
'use strict';
console.log(player.name); // Jennifer
Will print.