Created
December 22, 2016 07:46
-
-
Save gracefullight/8189627942b796f077a6891c7f6747e8 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
var frozenObject = { | |
value1 : 1, | |
value2 : 2 | |
}; | |
Object.freeze(frozenObject); | |
console.log(Object.isFrozen(frozenObject)); // true | |
// 삭제 불가 | |
delete frozenObject.value1; | |
console.log(frozenObject.value1); // 1 | |
// 변경 불가 | |
frozenObject.value2 = 3; | |
console.log(frozenObject.value2); // 2 | |
// 객체 추가 불가 | |
frozenObject.value3 = 3; | |
console.log(frozenObject.value3); // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment