Difference between freeze and seal

后端 未结 8 971
孤独总比滥情好
孤独总比滥情好 2020-12-07 08:00

I just heard about the JavaScript methods freeze and seal, which can be used to make any Object immutable.

Here\'s a short example how to u

8条回答
  •  囚心锁ツ
    2020-12-07 08:22

    Object.freeze() creates a frozen object, which means it takes an existing object and essentially calls Object.seal() on it, but it also marks all “data accessor” properties as writable:false, so that their values cannot be changed. - Kyle Simpson, You Don't Know JS - This & Object Prototypes

提交回复
热议问题