aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html116
1 files changed, 116 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html
new file mode 100644
index 0000000000..85eebfa1ce
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html
@@ -0,0 +1,116 @@
+---
+title: EvalError
+slug: Web/JavaScript/Reference/Global_Objects/EvalError
+translation_of: Web/JavaScript/Reference/Global_Objects/EvalError
+---
+<div>{{JSRef}}</div>
+
+<p>本对象代表了一个关于 <a href="/en/Core_JavaScript_1.5_Reference/Global_Functions/eval" title="en/Core_JavaScript_1.5_Reference/Global_Functions/eval">eval</a> 函数的错误.此异常不再会被JavaScript抛出,但是EvalError对象仍然保持兼容性.</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><code>new EvalError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre>
+
+<h3 id="Parameters" name="Parameters">参数</h3>
+
+<dl>
+ <dt>message</dt>
+ <dd>可选参数.人类可阅读的关于错误的描述.</dd>
+</dl>
+
+<dl>
+ <dt>fileName(非标准)</dt>
+ <dd>可选参数.代码中导致异常的文件的文件名.</dd>
+</dl>
+
+<dl>
+ <dt>lineNumber(非标准)</dt>
+ <dd>可选参数.代码中导致异常的代码的行号.</dd>
+</dl>
+
+<h2 id="Properties" name="Properties">属性</h2>
+
+<dl>
+ <dt><a href="/en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype" title="en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype">prototype</a></dt>
+ <dd>允许向EvalError对象中添加自定义属性.</dd>
+</dl>
+
+<h2 id="Methods" name="Methods">方法</h2>
+
+<p>全局的EvalError对象本身不包含任何方法, 然而它通过原型链继承了一些方法.</p>
+
+<h2 id="EvalError_实例"><code>EvalError</code> 实例</h2>
+
+<h3 id="属性">属性</h3>
+
+<p>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype', 'Properties')}}</p>
+
+<h3 id="方法">方法</h3>
+
+<p>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype', 'Methods')}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p><code>EvalError</code> 不在当前ECMAScript规范中使用,因此不会被运行时抛出. 但是对象本身仍然与规范的早期版本向后兼容.</p>
+
+<h3 id="创建_EvalError">创建 <code>EvalError</code></h3>
+
+<pre><code>try {
+ throw new EvalError('Hello', 'someFile.js', 10);
+} catch (e) {
+ console.log(e instanceof EvalError); // true
+ console.log(e.message); // "Hello"
+ console.log(e.name); // "EvalError"
+ console.log(e.fileName); // "someFile.js"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // "@Scratchpad/2:2:9\n"
+}</code></pre>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>初始定义.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.6.1', 'EvalError')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>本规范中未使用. 为了保持向后兼容.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-evalerror', 'EvalError')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>本规范中未使用. 为了保持向后兼容.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-evalerror', 'EvalError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>该页面中的兼容性表格由结构化的数据生成。如果有意向贡献数据,请查看 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并发起 pull request。</p>
+</div>
+
+<p>{{Compat("javascript.builtins.EvalError")}}</p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/en/Core_JavaScript_1.5_Reference/Global_Objects/Error" title="en/Core_JavaScript_1.5_Reference/Global_Objects/Error">Error</a></li>
+ <li><a href="/en/Core_JavaScript_1.5_Reference/Global_Functions/eval" title="en/Core_JavaScript_1.5_Reference/Global_Functions/eval">eval</a></li>
+ <li><a href="/en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype" title="en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype">EvalError.prototype</a></li>
+</ul>