Skip to content

Instantly share code, notes, and snippets.

@gracefullight
Created December 22, 2016 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gracefullight/8189627942b796f077a6891c7f6747e8 to your computer and use it in GitHub Desktop.
Save gracefullight/8189627942b796f077a6891c7f6747e8 to your computer and use it in GitHub Desktop.
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