diff options
| author | Ryan Johnson <rjohnson@mozilla.com> | 2021-04-29 16:16:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-29 16:16:42 -0700 |
| commit | 95aca4b4d8fa62815d4bd412fff1a364f842814a (patch) | |
| tree | 5e57661720fe9058d5c7db637e764800b50f9060 /files/fa/web/javascript/reference/errors | |
| parent | ee3b1c87e3c8e72ca130943eed260ad642246581 (diff) | |
| download | translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.gz translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.bz2 translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.zip | |
remove retired locales (#699)
Diffstat (limited to 'files/fa/web/javascript/reference/errors')
3 files changed, 0 insertions, 229 deletions
diff --git a/files/fa/web/javascript/reference/errors/index.html b/files/fa/web/javascript/reference/errors/index.html deleted file mode 100644 index c295fccea6..0000000000 --- a/files/fa/web/javascript/reference/errors/index.html +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: JavaScript error reference -slug: Web/JavaScript/Reference/Errors -tags: - - Debugging - - Error - - Errors - - Exception - - JavaScript - - NeedsTranslation - - TopicStub - - exceptions -translation_of: Web/JavaScript/Reference/Errors ---- -<p>{{jsSidebar("Errors")}}</p> - -<p>Below, you'll find a list of errors which are thrown by JavaScript. These errors can be a helpful debugging aid, but the reported problem isn't always immediately clear. The pages below will provide additional details about these errors. Each error is an object based upon the {{jsxref("Error")}} object, and has a <code>name</code> and a <code>message</code>.</p> - -<p>Errors displayed in the Web console may include a link to the corresponding page below to help you quickly comprehend the problem in your code.</p> - -<h2 id="List_of_errors">List of errors</h2> - -<p>In this list, each page is listed by name (the type of error) and message (a more detailed human-readable error message). Together, these two properties provide a starting point toward understanding and resolving the error. For more information, follow the links below!</p> - -<p>{{ListSubPages("/en-US/docs/Web/JavaScript/Reference/Errors")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Learn/JavaScript/First_steps/What_went_wrong">What went wrong? Troubleshooting JavaScript</a>: Beginner's introductory tutorial on fixing JavaScript errors.</li> -</ul> diff --git a/files/fa/web/javascript/reference/errors/too_much_recursion/index.html b/files/fa/web/javascript/reference/errors/too_much_recursion/index.html deleted file mode 100644 index 02a8d54c45..0000000000 --- a/files/fa/web/javascript/reference/errors/too_much_recursion/index.html +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: 'InternalError: too much recursion' -slug: Web/JavaScript/Reference/Errors/Too_much_recursion -translation_of: Web/JavaScript/Reference/Errors/Too_much_recursion ---- -<div>{{jsSidebar("Errors")}}</div> - -<h2 id="Message">Message</h2> - -<pre class="syntaxbox">Error: Out of stack space (Edge) -InternalError: too much recursion (Firefox) -RangeError: Maximum call stack size exceeded (Chrome) -</pre> - -<h2 id="Error_type">Error type</h2> - -<p>{{jsxref("InternalError")}}.</p> - -<h2 id="What_went_wrong">What went wrong?</h2> - -<p>A function that calls itself is called a <em>recursive function</em>. Once a condition is met, the function stops calling itself. This is called a <em>base case</em>.</p> - -<p>In some ways, recursion is analogous to a loop. Both execute the same code multiple times, and both require a condition (to avoid an infinite loop, or rather, infinite recursion in this case). <span class="seoSummary">When there are too many function calls, or a function is missing a base case, JavaScript will throw this error.</span></p> - -<h2 id="Examples">Examples</h2> - -<p>This recursive function runs 10 times, as per the exit condition.</p> - -<pre class="brush: js">function loop(x) { - if (x >= 10) // "x >= 10" is the exit condition - return; - // do stuff - loop(x + 1); // the recursive call -} -loop(0);</pre> - -<p>Setting this condition to an extremely high value, won't work:</p> - -<pre class="brush: js example-bad">function loop(x) { - if (x >= 1000000000000) - return; - // do stuff - loop(x + 1); -} -loop(0); - -// InternalError: too much recursion</pre> - -<p>This recursive function is missing a base case. As there is no exit condition, the function will call itself infinitely.</p> - -<pre class="brush: js example-bad">function loop(x) { - // The base case is missing - -loop(x + 1); // Recursive call -} - -loop(0); - -// InternalError: too much recursion</pre> - -<h3 id="Class_error_too_much_recursion">Class error: too much recursion</h3> - -<pre class="brush: js example-bad">class Person{ - constructor(){} - set name(name){ - this.name = name; // Recursive call - } -} - - -const tony = new Person(); -tony.name = "Tonisha"; // InternalError: too much recursion -</pre> - -<p>When a value is assigned to the property name (this.name = name;) JavaScript needs to set that property. When this happens, the setter function is triggered.</p> - -<pre class="brush: js example-bad">set name(name){ - this.name = name; // Recursive call -} -</pre> - -<div class="note"> -<p>In this example when the setter is triggered, it is told to do the same thing again: <em>to set the same property that it is meant to handle.</em> This causes the function to call itself, again and again, making it infinitely recursive.</p> -</div> - -<p>This issue also appears if the same variable is used in the getter.</p> - -<pre class="brush: js example-bad">get name(){ - return this.name; // Recursive call -} -</pre> - -<p>To avoid this problem, make sure that the property being assigned to inside the setter function is different from the one that initially triggered the setter.The same goes for the getter.</p> - -<pre class="brush: js">class Person{ - constructor(){} - set name(name){ - this._name = name; - } - get name(){ - return this._name; - } -} -const tony = new Person(); -tony.name = "Tonisha"; -console.log(tony); -</pre> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{Glossary("Recursion")}}</li> - <li><a href="/en-US/docs/Web/JavaScript/Guide/Functions#Recursion">Recursive functions</a></li> -</ul> diff --git a/files/fa/web/javascript/reference/errors/unexpected_token/index.html b/files/fa/web/javascript/reference/errors/unexpected_token/index.html deleted file mode 100644 index 77fa2e06c5..0000000000 --- a/files/fa/web/javascript/reference/errors/unexpected_token/index.html +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: 'SyntaxError: Unexpected token' -slug: Web/JavaScript/Reference/Errors/Unexpected_token -translation_of: Web/JavaScript/Reference/Errors/Unexpected_token ---- -<div class="twocolumns"> - -</div> - -<div class="threecolumns"> -<p>{{jsSidebar("Errors")}}</p> -</div> - -<p>The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided. This might be a simple typo.</p> - -<h2 id="Message">Message</h2> - -<pre class="syntaxbox notranslate">SyntaxError: expected expression, got "x" -SyntaxError: expected property name, got "x" -SyntaxError: expected target, got "x" -SyntaxError: expected rest argument name, got "x" -SyntaxError: expected closing parenthesis, got "x" -SyntaxError: expected '=>' after argument list, got "x" -</pre> - -<h2 id="Error_type">Error type</h2> - -<p>{{jsxref("SyntaxError")}}</p> - -<h2 id="What_went_wrong">What went wrong?</h2> - -<p>A specific language construct was expected, but something else was provided. This might be a simple typo.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Expression_expected">Expression expected</h3> - -<p>For example, when chaining expressions, trailing commas are not allowed.</p> - -<pre class="brush: js example-bad notranslate">for (let i = 0; i < 5,; ++i) { - console.log(i); -} -// SyntaxError: expected expression, got ')' -</pre> - -<p>Correct would be omitting the comma or adding another expression:</p> - -<pre class="brush: js example-good notranslate">for (let i = 0; i < 5; ++i) { - console.log(i); -} -</pre> - -<h3 id="Not_enough_brackets">Not enough brackets</h3> - -<p>Sometimes, you leave out brackets around <code>if</code> statements:</p> - -<pre class="brush: js example-bad line-numbers language-js notranslate">function round(n, upperBound, lowerBound){ - if(n > upperBound) || (n < lowerBound){ - throw 'Number ' + String(n) + ' is more than ' + String(upperBound) + ' or less than ' + String(lowerBound); - }else if(n < ((upperBound + lowerBound)/2)){ - return lowerBound; - }else{ - return upperBound; - } -} // SyntaxError: expected expression, got '||'</pre> - -<p>The brackets may look correct at first, but note how the <code>||</code> is outside the brackets. Correct would be putting brackets around the <code>||</code>:</p> - -<pre class="brush: js example-good notranslate">function round(n, upperBound, lowerBound){ - if((n > upperBound) || (n < lowerBound)){ - throw 'Number ' + String(n) + ' is more than ' + String(upperBound) + ' or less than ' + String(lowerBound); - }else if(n < ((upperBound + lowerBound)/2)){ - return lowerBound; - }else{ - return upperBound; - } -} -</pre> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{jsxref("SyntaxError")}}</li> -</ul> |
