Last active
July 8, 2016 18:15
-
-
Save johnmmoss/937049a448a64fe1d5d56ee4304345e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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