类:TypeError
¥Class: TypeError
-
¥Extends <errors.Error>
表示提供的参数不是允许的类型。例如,将函数传给期望字符串为 TypeError
的参数。
¥Indicates that a provided argument is not an allowable type. For example,
passing a function to a parameter which expects a string would be a TypeError
.
require('node:url').parse(() => { });
// Throws TypeError, since it expected a string.
Node.js 将立即生成并抛出 TypeError
实例作为参数验证的一种形式。
¥Node.js will generate and throw TypeError
instances immediately as a form
of argument validation.