Movatterモバイル変換


[0]ホーム

URL:


  1. 개발자를 위한 웹 기술
  2. JavaScript
  3. JavaScript 참고서
  4. JavaScript error reference
  5. InternalError: too much recursion

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

InternalError: too much recursion

메시지

    InternalError: too much recursion

에러 형식

InternalError.

무엇이 잘못되었을까?

자신을 호출하는 함수를 재귀 함수라고 합니다. 어떤 면에서, 재귀는 반복과 유사합니다. 둘 다 같은 코드를 여러 번 실행하며, 조건(무한 반복 피하기, 더 정확히 여기서 말하는 무한 재귀)이 있습니다. 너무 많거나 무한 번의 재귀가 발생할 경우, JavaScript는 이 에러를 던질 것입니다.

이 재귀 함수는 exit 조건에 따라 10번을 실행합니다.

js
function loop(x) {  if (x >= 10) {    // "x >= 10" is the exit condition    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

참조

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp