Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 2, 2014 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/926cc7be742c9459283d to your computer and use it in GitHub Desktop.
Save devdays/926cc7be742c9459283d to your computer and use it in GitHub Desktop.
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