Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:22
Show Gist options
  • Select an option

  • Save psiborg/1569666 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/1569666 to your computer and use it in GitHub Desktop.
JS Objects
// object literal
var myObj = {
property1: 42,
property2: "Hello",
property3: true
};
// loop over properties
for (var i in myObj) {
console.log(i + ': ' + myObj[i]);
}
// deleting a property
delete myObj.property1; // undefined
// changing a value
myObj.property2 = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment