javascript - 引发 EvalError 和 InternalError

标签 javascript exception

当我查找 javascript 错误类型时,我发现有 7 种错误类型,如 MDN 。 我可以生成所有核心五个错误,例如 SyntaxErrorReferenceErrorRangeErrorURIErrorTypeError.

但是,我找不到生成其他 2 种错误类型 EvalErrorInternalError 的方法。我如何生成这个? (或者)是否有任何示例 javascript 代码会引发此错误?

最佳答案

来自 ES5 specification :

15.11.6.1 EvalError
This exception is not currently used within this specification. This object remains for compatibility with previous editions of this specification.

所以我猜这个错误在现代浏览器中不会产生。

关于InternalError,您链接到的页面显示:

InternalError
Creates an instance representing an error that occurs when an internal error in the JavaScript engine is thrown. E.g. "too much recursion".

确实,运行

function foo() {
  foo();
}
foo();

抛出

InternalError: too much recursion

关于javascript - 引发 EvalError 和 InternalError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26258583/

相关文章:

javascript - 如何制作小数点javascript?

c# - 为什么 finally 没有被执行?

android - XML 预览中的呈现问题 : Unable to locate mode 0

javascript - react 16 : Call children's function from parent when using hooks and functional component

javascript - 选择兄弟节点时如何递归取消选择堂兄弟节点(递归呈现的复选框)

javascript - jQuery 点击函数的不同方法

java - 如何将 NumberFormatException 设置为标签

javascript - Windows Azure + DevExpress(手机)获取待办事项列表(标准示例)

java - 使用观察者模式在模型中抛出异常

swift - “ fatal error :在展开可选值时意外发现nil”是什么意思?