Created
November 19, 2014 13:49
-
-
Save shaunwallace/2d6ee5c6cc7e6244bc10 to your computer and use it in GitHub Desktop.
Object.freeze()
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
| // 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