InternalError

非標準:此特性未標準化。我們不建議在生產環境中使用非標準特性,因為它們瀏覽器支援有限,並且可能會更改或被移除。但是,在沒有標準選項的特定情況下,它們可以是合適的替代方案。

InternalError 物件指示 JavaScript 引擎內部發生的錯誤。

示例如下,通常是由於某些東西“太大”而引起的,例如:

  • "switch 語句的 case 過多",
  • "正則表示式中的括號過多",
  • "陣列初始化器過大",
  • "遞迴過深"。

InternalErrorError 的一個子類。

建構函式

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(遞迴過深)

規範

不屬於任何標準。

瀏覽器相容性

另見