aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html
new file mode 100644
index 0000000000..7697c1074d
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/string/valueof/index.html
@@ -0,0 +1,58 @@
+---
+title: String.prototype.valueOf()
+slug: Web/JavaScript/Reference/Global_Objects/String/valueOf
+translation_of: Web/JavaScript/Reference/Global_Objects/String/valueOf
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>valueOf()</code></strong> 方法返回  {{jsxref("String")}}  对象的原始值</p>
+
+<div>{{EmbedInteractiveExample("pages/js/string-valueof.html")}}</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate"><code><var>str</var>.valueOf()</code></pre>
+
+<h3 id="返回结果">返回结果</h3>
+
+<p>A string representing the primitive value of a given {{jsxref("String")}} object.</p>
+
+<h2 id="描述">描述</h2>
+
+<p>The <code>valueOf()</code> method of {{jsxref("String")}} returns the primitive value of a {{jsxref("String")}} object as a string data type. This value is equivalent to {{jsxref("String.prototype.toString()")}}.</p>
+
+<p>此方法通常由JavaScript在内部调用,而不是在代码中显式调用。</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="使用_valueOf">使用 <code>valueOf()</code></h3>
+
+<pre class="brush: js notranslate">var x = new String('Hello world');
+console.log(x.valueOf()); // Displays 'Hello world'
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.prototype.valueof', 'String.prototype.valueOf')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">此页中的兼容性表是从结构化数据生成的。如果你想对数据有所贡献,请查看<a href="/zh-CN/docs/">https://github.com/mdn/browser-compat-data</a>并向我们发送请求。</p>
+
+<p>{{Compat("javascript.builtins.String.valueOf")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{jsxref("String.prototype.toString()")}}</li>
+ <li>{{jsxref("Object.prototype.valueOf()")}}</li>
+</ul>