napi_has_own_property


napi_status napi_has_own_property(napi_env env,
                                  napi_value object,
                                  napi_value key,
                                  bool* result); 
  • [in] env:调用 Node-API 调用的环境。

    ¥[in] env: The environment that the Node-API call is invoked under.

  • [in] object:要查询的对象。

    ¥[in] object: The object to query.

  • [in] key:要检查其存在的自有属性的名称。

    ¥[in] key: The name of the own property whose existence to check.

  • [out] result:对象上是否存在自己的属性。

    ¥[out] result: Whether the own property exists on the object or not.

如果 API 成功,则返回 napi_ok

¥Returns napi_ok if the API succeeded.

此 API 检查传入的 Object 是否具有命名的自己的属性。key 必须是 stringsymbol,否则将抛出错误。Node-API 不会执行任何数据类型之间的转换。

¥This API checks if the Object passed in has the named own property. key must be a string or a symbol, or an error will be thrown. Node-API will not perform any conversion between data types.