TypeError 类


表明提供的参数不是被允许的类型。 例如,将函数传给期望字符串的参数,将会被视为 TypeError

require('url').parse(() => { });
// 抛出 TypeError,因为它期望的是字符串。

Node.js 将会以参数验证的形式立即地生成并抛出 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 considered a TypeError.

require('url').parse(() => { });
// Throws TypeError, since it expected a string.

Node.js will generate and throw TypeError instances immediately as a form of argument validation.