Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 19, 2014 13:49
Show Gist options
  • Select an option

  • Save shaunwallace/2d6ee5c6cc7e6244bc10 to your computer and use it in GitHub Desktop.

Select an option

Save shaunwallace/2d6ee5c6cc7e6244bc10 to your computer and use it in GitHub Desktop.
Object.freeze()
// create empty object
var obj13 = Object.create({});
// adding some properties
obj13.foo = 'x';
obj13.bar = 'y';
Object.freeze( obj13 ); // freezes the object completely
// after being frozen we can not alter the object
obj13.baz = 'z';
obj13.foo = false;
obj13; // returns {foo: "x", bar: "y"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment