Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created October 9, 2017 14:30
Show Gist options
  • Save JamesTheHacker/aa1b0c49272537792dbe46eb8d43477b to your computer and use it in GitHub Desktop.
Save JamesTheHacker/aa1b0c49272537792dbe46eb8d43477b to your computer and use it in GitHub Desktop.
// 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