From 0a53e0a3cf57d6153f76eb6d2e165ae6aa5bfaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Fri, 31 Jul 2020 13:54:24 +0200 Subject: [PATCH] doc: mention null special-case for `napi_typeof` The documentation said `napi_typeof` is similar to the `typeof` operator, but the `typeof null` detects `'object'` while `napi_typeof(a_null_value)` detects `napi_null`. --- doc/api/n-api.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index f45dd2dd4c6951..f462dbb1c58b42 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3149,7 +3149,12 @@ Returns `napi_ok` if the API succeeded. This API represents behavior similar to invoking the `typeof` Operator on the object as defined in [Section 12.5.5][] of the ECMAScript Language -Specification. However, it has support for detecting an External value. +Specification. However, there are some differences: + +1. It has support for detecting an External value. +2. It detects `null` as a separate type, while ECMAScript `typeof` would detect + `object`. + If `value` has a type that is invalid, an error is returned. ### napi_instanceof