aboutsummaryrefslogtreecommitdiff
path: root/files/vi/web/javascript/reference/errors/too_much_recursion
diff options
context:
space:
mode:
Diffstat (limited to 'files/vi/web/javascript/reference/errors/too_much_recursion')
-rw-r--r--files/vi/web/javascript/reference/errors/too_much_recursion/index.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/files/vi/web/javascript/reference/errors/too_much_recursion/index.html b/files/vi/web/javascript/reference/errors/too_much_recursion/index.html
new file mode 100644
index 0000000000..a4851c4f56
--- /dev/null
+++ b/files/vi/web/javascript/reference/errors/too_much_recursion/index.html
@@ -0,0 +1,54 @@
+---
+title: 'InternalError: Quá nhiều đệ quy'
+slug: Web/JavaScript/Reference/Errors/qua_nhieu_de_quy
+tags:
+ - JavaScript
+ - Lỗi
+ - Lỗi bên trong
+translation_of: Web/JavaScript/Reference/Errors/Too_much_recursion
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Thông_điệp">Thông điệp</h2>
+
+<pre class="syntaxbox">InternalError: too much recursion
+</pre>
+
+<h2 id="Loại_lỗi">Loại lỗi</h2>
+
+<p>{{jsxref("InternalError")}}.</p>
+
+<h2 id="Lỗi_phát_sinh_ra_khi_nào">Lỗi phát sinh ra khi nào?</h2>
+
+<p>Một hàm gọi chính nó được gọi là hàm đệ quy . Trong một số trường hợp, đệ quy tương tự như một vòng lặp. Cả hai đều thực hiện cùng một mã nhiều lần, Và cả hai đều yêu cầu một điều kiện ( Để tránh một vòng lặp vô hạn, hoặc đúng hơn, đệ quy vô hạn trong trường hợp này ). <span class="seoSummary"> Khi có quá nhiều hoặc vô hạn đệ quy, JavaScript sẽ ném lỗi này.</span></p>
+
+<h2 id="Ví_dụ">Ví dụ</h2>
+
+<p>Chức năng đệ quy này chạy 10 lần, theo điều kiện x &gt;= 10 .</p>
+
+<pre class="brush: js">function loop(x) {
+ if (x &gt;= 10) // "x &gt;= 10" là điều kiện dừng
+ return;
+ // do stuff
+ loop(x + 1); // gọi lại chính nó (đệ quy)
+}
+loop(0);</pre>
+
+<p>Đặt điều kiện này lên một giá trị rất cao, sẽ không hoạt động:</p>
+
+<pre class="brush: js example-bad">function loop(x) {
+ if (x &gt;= 1000000000000)
+ return;
+ // do stuff
+ loop(x + 1);
+}
+loop(0);
+
+// InternalError: too much recursion</pre>
+
+<h2 id="Xem_thêm">Xem thêm</h2>
+
+<ul>
+ <li>{{Glossary("Recursion")}}</li>
+ <li><a href="/en-US/docs/Web/JavaScript/Guide/Functions#Recursion">Recursive functions</a></li>
+</ul>