pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Errors/Too_much_recursion

tic/client/1111.53dba753dc3eb961.js" type="module">

Esta página ha sido traducida del inglés por la comunidad. Aprende más y únete a la comunidad de MDN Web Docs.

View in English Always switch to English

InternalError: too much recursion

Mensaje

InternalError: too much recursion

Tipo de error

InternalError.

¿Qué ha ido mal?

Una función que se llama a sí misma es una función recursiva. Podemos decir que la recursión es análoga a un bucle. Ambos ejecutan el mismo código varias veces y ambos requieren de una condición de fin (para evitar un bucle infinito o recursión infinita). Cuando hay recursión infinita o mucha recursión, JavaScript lanza este error.

Ejemplos

Esta función recursiva se ejecuta 10 veces, debido a la condición de salida.

js
function loop(x) {
  if (x >= 10) {
    // "x >= 10" es la condición de salida
    return;
  }
  // hacer cosas
  loop(x + 1); // llamada recursiva
}
loop(0);

Si establecemos esta condición para un valor muy alto, no funcionará:

js
function loop(x) {
  if (x >= 1000000000000) {
    return;
  }
  // hacer cosas
  loop(x + 1);
}
loop(0);

// InternalError: too much recursion (demasiada recursión)

See also

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy