Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object JavaScript - Literals in Action
var empty = {}; // An object with no properties
var point = { x:0, y:0 }; // Two properties
var point2 = { x:point.x, y:point.y+1 }; // More complex values
var book = {
/* property names can include spaces and hyphen
and quoted reserved words. */
"main title": "HTML5",
'sub-title': "For All Devices",
"for": "age 13 and up",
// And can include another object
author: {
firstname: "Bruce",
lastname: "Kyle"
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment