找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 722|回复: 0

The result will be an error

[复制链接]

1

主题

0

回帖

5

积分

新手上路

积分
5
发表于 2023-12-21 18:40:53 | 显示全部楼层 |阅读模式
When copying an object copying IDs usually doesn't make sense. Also disabling enumeration for properties containing sensitive data may make a lot of sense. Writable and configurable Setting writableto falseprevents the property from being overwritten. It will still be possible to delete a given property and modify its descriptor. It is worth noting that attempting to overwrite a value will not result in an error unless the script is running in mode strict.

In this case an error will be thrown Cannot assign to read only property 'price' of object <Object>. const pineapple price pineapple 'price'  . Attempts to extend the object with new properties will not cause errors. Enabling Phone Number List the mode strictwill cause an attempt to modify a frozen object to result in an error Cannot add property property_name object is not extensible. A similar effect will be achieved by trying to modify a frozen array.





Using the push and methods unshift .with the content Cannot add property object is not extensible. For arrays this behavior occurs regardless of whether the script is run in mode strictor not. The method differs Object.seal from Obje.freeze in that the properties of the object on which the method is invoked Object.seal are still modifiable. As with it Oe is not possible to extend an object and all properties are not configurable.

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表