Skip to content
napi-bindings

Search

Search pages, projects and the Node-API reference

Browse Node-APIshow

napi_coerce_to_number

functionv1js_native_api.h

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

napi_status napi_coerce_to_number(napi_env env,
                                  napi_value value,
                                  napi_value* result)
  • [in] env: The environment that the API is invoked under.
  • [in] value: The JavaScript value to coerce.
  • [out] result: napi_value representing the coerced JavaScript number.

Returns napi_ok if the API succeeded.

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

View in the official Node.js documentation