napi_object_freeze
napi_status napi_object_freeze(napi_env env,
napi_value object);
-
[in] env
:调用 Node-API 调用的环境。¥
[in] env
: The environment that the Node-API call is invoked under. -
[in] object
:要冻结的对象。¥
[in] object
: The object to freeze.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此方法冻结给定的对象。这可以防止向其添加新属性,删除现有属性,防止更改现有属性的可枚举性、可配置性或可写性,并防止更改现有属性的值。它还可以防止对象的原型被更改。这在 ECMA-262 规范的 第 19.1.2.6 节 中进行了描述。
¥This method freezes a given object. This prevents new properties from being added to it, existing properties from being removed, prevents changing the enumerability, configurability, or writability of existing properties, and prevents the values of existing properties from being changed. It also prevents the object's prototype from being changed. This is described in Section 19.1.2.6 of the ECMA-262 specification.