aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/uneval
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/uneval')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/uneval/index.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html b/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html
new file mode 100644
index 0000000000..38d7959076
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html
@@ -0,0 +1,68 @@
+---
+title: uneval()
+slug: Web/JavaScript/Reference/Global_Objects/uneval
+tags:
+ - JavaScript
+translation_of: Web/JavaScript/Reference/Global_Objects/uneval
+---
+<div>{{jsSidebar("Objects")}}{{Non-standard_header}}</div>
+
+<p><code><strong>uneval()</strong></code> 函数创建一个代表对象的源代码的字符串。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">uneval(<var>object</var>)</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>object</code></dt>
+ <dd>JavaScript 表达式或者语句</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<dl>
+ <dd>表示给定对象的源代码的字符串</dd>
+</dl>
+
+<div class="note"><strong>注意:</strong>无法通过此方法获取对象的 JSON 形式。</div>
+
+<h2 id="描述">描述</h2>
+
+<p><code>uneval()</code> 是一个顶级函数并且不与任何对象关联</p>
+
+<h2 id="实例">实例</h2>
+
+<pre class="brush:js">var a = 1;
+uneval(a); // returns a String containing 1
+
+var b = "1";
+uneval(b) // returns a String containing "1"
+
+uneval(function foo(){}); // returns "(function foo(){})"
+
+
+var a = uneval(function foo(){return 'hi'});
+var foo = eval(a);
+foo(); // returns "hi"
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<p>不属于任何规范的一部分。</p>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+<div class="hidden">The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div>
+
+<p>{{Compat("javascript.builtins.uneval")}}</p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li>{{jsxref("Global_Objects/eval", "eval()")}}</li>
+ <li>{{jsxref("JSON.stringify")}}</li>
+ <li>{{jsxref("JSON.parse")}}</li>
+ <li>{{jsxref("Object.toSource")}}</li>
+</ul>