Last active
May 4, 2022 18:44
-
-
Save anibal21/ec431f7907937b2d7ffad54f36a19674 to your computer and use it in GitHub Desktop.
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
/** | |
* 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