mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 15:34:05 +08:00
29 lines
1.5 KiB
HTML
29 lines
1.5 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<h2 id="信息">信息</h2>
|
||
<pre><code class="language-javascript">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"
|
||
</code></pre>
|
||
<h2 id="错误类型">错误类型</h2>
|
||
<p><a href="Reference/Global_Objects/SyntaxError" title="SyntaxError 对象代表尝试解析语法上不合法的代码的错误。"><code>SyntaxError</code></a></p>
|
||
<h2 id="哪里出错了">哪里出错了?</h2>
|
||
<p>期望获得一个特定的语法结构,但得到了其他的。 可能只是一个简单的错字。</p>
|
||
<h2 id="示例">示例</h2>
|
||
<h3 id="期望的表达式">期望的表达式</h3>
|
||
<p>例如,在调用函数时,不允许使用尾随逗号。 有尾逗号的时候,JavaScript 会期望有另一个参数,可以是任何表达式。</p>
|
||
<pre><code class="language-js example-bad">Math.max(2, 42,);
|
||
// SyntaxError: expected expression, got ')'
|
||
</code></pre>
|
||
<p>正确的方法是省略最后一个逗号或添加另一个参数:</p>
|
||
<pre><code class="language-js example-good">Math.max(2, 42);
|
||
Math.max(2, 42, 13+37);
|
||
</code></pre>
|
||
<h2 id="相关">相关</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/Math/max" title="Math.max() 函数返回一组数中的最大值。"><code>Math.max()</code></a></li>
|
||
</ul>
|
||
</article> |