Skip to content

Instantly share code, notes, and snippets.

@johnmmoss
Last active July 8, 2016 18:15
Show Gist options
  • Save johnmmoss/937049a448a64fe1d5d56ee4304345e2 to your computer and use it in GitHub Desktop.
Save johnmmoss/937049a448a64fe1d5d56ee4304345e2 to your computer and use it in GitHub Desktop.
var cat = { name: 'Felix', color:'blue' }
// We can view the properties in the object by simply looping through:
for(var property in cat) {
document.write(key + ": " + cat[property] + ";"); // name: Felix; color:blue;
}
// Now we set enumerable to false
Object.defineProperty(cat, ‘name’, {ennumerable: false})
// name does not get ennumerated
for(var property in cat) {
document.write(key + ": " + cat[property] + ";"); // color:blue;
}
// We can use the keys object to access an array of the keys
// Returns ['name', 'color']
Object.keys(cat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment