InternalError
非标准:此特性未标准化。我们不建议在生产环境中使用非标准特性,因为它们浏览器支持有限,并且可能会更改或被移除。但是,在没有标准选项的特定情况下,它们可以是合适的替代方案。
InternalError 对象指示 JavaScript 引擎内部发生的错误。
示例如下,通常是由于某些东西“太大”而引起的,例如:
- "switch 语句的 case 过多",
- "正则表达式中的括号过多",
- "数组初始化器过大",
- "递归过深"。
InternalError 是 的一个子类。Error
构造函数
InternalError()非标准-
创建一个新的
InternalError对象。
实例属性
还继承了其父级 Error 的实例属性。.
这些属性定义在 InternalError.prototype 上,并由所有 InternalError 实例共享。
InternalError.prototype.constructor-
创建实例对象的构造函数。对于
InternalError实例,初始值为构造函数。InternalError InternalError.prototype.name-
表示错误类型的名称。对于
InternalError.prototype.name,初始值为"InternalError"。
实例方法
继承了其父级 Error 的实例方法。.
示例
递归过深
此递归函数根据退出条件运行 10 次。
js
function loop(x) {
// "x >= 10" is the exit condition
if (x >= 10) return;
// do stuff
loop(x + 1); // the recursive call
}
loop(0);
将此条件设置为非常大的值可能不起作用。
js
function loop(x) {
if (x >= 1000000000000) return;
// do stuff
loop(x + 1);
}
loop(0);
// InternalError: too much recursion
有关更多信息,请参阅 InternalError: too much recursion(递归过深)。
规范
不属于任何标准。
浏览器兼容性
加载中…