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/unexpected_token/index.html | |
| 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/unexpected_token/index.html')
| -rw-r--r-- | files/fa/web/javascript/reference/errors/unexpected_token/index.html | 84 |
1 files changed, 0 insertions, 84 deletions
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> |
