Javascript Object.freeze() does not prevent changes to object

后端 未结 3 959
小鲜肉
小鲜肉 2020-12-11 06:01

I am trying to understand the Object.freeze method of ECMAscript.

My understanding was that it essentially stops changes to all the properties of an object. MDN docu

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 06:38

    Set the property descriptors for the object to writable:false, configurable:false using Object.defineProprties; then call Object.preventExtensions on the object. See How to create static array in javascript.

提交回复
热议问题