Skip to content

Instantly share code, notes, and snippets.

@anibal21
Last active May 4, 2022 18:44
Show Gist options
  • Save anibal21/ec431f7907937b2d7ffad54f36a19674 to your computer and use it in GitHub Desktop.
Save anibal21/ec431f7907937b2d7ffad54f36a19674 to your computer and use it in GitHub Desktop.
/**
* When we do a freeze to an object, we only can read their items.
*/
const obj = {
prop: 42
};
Object.freeze(obj);
obj.prop = 55;
obj.name = "Julio"
// Throws an error in strict mode
console.log(obj.prop);
// expected output: 42
console.log(obj.name)
// expected output: undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment