Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 19, 2014 12:37
Show Gist options
  • Save shaunwallace/77d81ba16a754071475c to your computer and use it in GitHub Desktop.
Save shaunwallace/77d81ba16a754071475c to your computer and use it in GitHub Desktop.
Object.defineProperties()
var obj8 = {};
Object.defineProperties(obj8, {
foo : {
value : 100,
configurable : false,
enumerable : true
},
bar : {
value : 300,
writable : true
}
});
Object.keys( obj8 ); // returns ["foo"]
obj8.foo = 500;
obj8.foo; // returns 100
obj8.bar = 1000;
obj8.bar; // returns 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment