napi_coerce_to_string


napi_status napi_coerce_to_string(napi_env env,
                                  napi_value value,
                                  napi_value* result) 
  • [in] env:调用 API 的环境。

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

  • [in] value:要强制转换的 JavaScript 值。

    ¥[in] value: The JavaScript value to coerce.

  • [out] resultnapi_value 代表强制的 JavaScript string

    ¥[out] result: napi_value representing the coerced JavaScript string.

如果 API 成功,则返回 napi_ok

¥Returns napi_ok if the API succeeded.

该 API 实现了 ECMAScript 语言规范的 第 7.1.13 节 中定义的抽象操作 ToString()。如果传入的值是对象,此函数可能会运行 JS 代码。

¥This API implements the abstract operation ToString() as defined in Section 7.1.13 of the ECMAScript Language Specification. This function potentially runs JS code if the passed-in value is an object.