类:RangeError


¥Class: 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('node:net').connect(-1);
// Throws "RangeError: "port" option should be >= 0 and < 65536: -1" 

Node.js 将立即生成并抛出 RangeError 实例作为参数验证的一种形式。

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