Is there any way to prevent replacement of JavaScript object properties?

后端 未结 6 1938
醉酒成梦
醉酒成梦 2020-12-16 00:21

I would like to make an object\'s structure immutable, preventing its properties from being subsequently replaced. The properties need to be readable, however. Is this possi

6条回答
  •  盖世英雄少女心
    2020-12-16 01:24

    ECMAScript 5 will have seal() and freeze(), but there's no good way to do this with current JavaScript implementations.

    Source.

提交回复
热议问题