Created
October 9, 2017 14:30
-
-
Save JamesTheHacker/aa1b0c49272537792dbe46eb8d43477b to your computer and use it in GitHub Desktop.
This file contains 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
// Shallow freeze | |
Object.freeze(state); | |
// This will not work | |
state.twitter = '@zuck'; | |
// Look, it's still @JamesJefferyUK | |
console.log(state.twitter); | |
// But this works because we're modifying a reference value (an object) | |
state.tweets[3] = 'I Love Facebook!'; | |
// I Love Facebook! | |
console.log(state.tweets[3]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment