RangeError 类


表明提供的参数不在函数的可接受值的集合或范围内;无论是一个数字范围,还是在给定的函数参数的选项的集合之外。

require('net').connect(-1);
// 抛出 "RangeError: "port" option should be >= 0 and < 65536: -1"

Node.js 将会以参数验证的形式立即地生成并抛出 RangeError 实例。

Indicates that a provided argument was not within the set or range of acceptable values for a function; whether that is a numeric range, or outside the set of options for a given function parameter.

require('net').connect(-1);
// Throws "RangeError: "port" option should be >= 0 and < 65536: -1"

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