Working with JavaScript values and abstract operations
Source: Node.js documentationNode-API exposes a set of APIs to perform some abstract operations on JavaScript values.
These APIs support doing one of the following:
- Coerce JavaScript values to specific JavaScript types (such as
numberorstring). - Check the type of a JavaScript value.
- Check for equality between two JavaScript values.
APIs in this section
Working with JavaScript values and abstract operations
napi_coerce_to_boolv1This API implements the abstract operation ToBoolean() as defined in Section ToBoolean of the ECMAScript Language Specification.napi_coerce_to_numberv1This 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_coerce_to_objectv1This API implements the abstract operation ToObject() as defined in Section ToObject of the ECMAScript Language Specification.napi_coerce_to_stringv1This API implements the abstract operation ToString() as defined in Section ToString of the ECMAScript Language Specification. This function potentially runs JS code if the passed-in value is an object.napi_typeofv1This API represents behavior similar to invoking the typeof Operator on the object as defined in Section typeof operator of the ECMAScript Language Specification. However, there are some differences:napi_instanceofv1This API represents invoking the instanceof Operator on the object as defined in Section instanceof operator of the ECMAScript Language Specification.napi_is_arrayv1This API represents invoking the IsArray operation on the object as defined in Section IsArray of the ECMAScript Language Specification.napi_is_arraybufferv1This API checks if the Object passed in is an array buffer.napi_is_bufferv1This API checks if the Object passed in is a buffer or Uint8Array. napi_is_typedarray should be preferred if the caller needs to check if the value is a Uint8Array.napi_is_datev5This API checks if the Object passed in is a date.napi_is_typedarrayv1This API checks if the Object passed in is a typed array.napi_is_dataviewv1This API checks if the Object passed in is a DataView.napi_strict_equalsv1This API represents the invocation of the Strict Equality algorithm as defined in Section IsStrictlyEqual of the ECMAScript Language Specification.napi_detach_arraybufferv7Generally, an ArrayBuffer is non-detachable if it has been detached before. The engine may impose additional conditions on whether an ArrayBuffer is detachable.napi_is_detached_arraybufferv7The ArrayBuffer is considered detached if its internal data is null.node_api_is_sharedarraybufferexperimentalThis API checks if the Object passed in is a SharedArrayBuffer.node_api_create_sharedarraybufferexperimentalThis API returns a Node-API value corresponding to a JavaScript SharedArrayBuffer. SharedArrayBuffers are used to represent fixed-length binary data buffers that can be shared across multiple workers.