util.types
util.types
为不同种类的内置对象提供类型检查。
与 instanceof
或 Object.prototype.toString.call(value)
不同,这些检查不检查可从 JavaScript 访问的对象的属性(如它们的原型),并且通常具有调用 C++ 的开销。
结果通常不会对值在 JavaScript 中公开的属性或行为类型做出任何保证。 它们主要对喜欢在 JavaScript 中进行类型检查的插件开发者有用。
util.types
provides type checks for different kinds of built-in objects.
Unlike instanceof
or Object.prototype.toString.call(value)
, these checks do
not inspect properties of the object that are accessible from JavaScript (like
their prototype), and usually have the overhead of calling into C++.
The result generally does not make any guarantees about what kinds of properties or behavior a value exposes in JavaScript. They are primarily useful for addon developers who prefer to do type checking in JavaScript.