From 0a9389bb1adfe7ca0f5084c945d62e843d8b1afd 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`. PR-URL: https://github.com/nodejs/node/pull/34577 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gabriel Schulhof Reviewed-By: Luigi Pinca Reviewed-By: David Carlier --- 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 676b08f37306b1..bc02572bf07ed8 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3165,7 +3165,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