aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/boolean/valueof')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html83
1 files changed, 83 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html
new file mode 100644
index 0000000000..068e594b92
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html
@@ -0,0 +1,83 @@
+---
+title: Boolean.prototype.valueOf()
+slug: Web/JavaScript/Reference/Global_Objects/Boolean/valueOf
+tags:
+ - Boolean
+ - JavaScript
+ - Method
+ - Prototype
+translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/valueOf
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>valueOf()</strong></code> 方法返回一个{{jsxref("Boolean")}}对象的原始值。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/boolean-valueof.html")}}</div>
+
+
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><code><var>bool</var>.valueOf()</code></pre>
+
+<h3 id="返回值">返回值</h3>
+
+<p>给定{{jsxref("Boolean")}}对象的原始值</p>
+
+<h2 id="Description" name="Description">描述</h2>
+
+<p>{{jsxref("Boolean")}}的 <code>valueOf</code> 方法返回一个{{jsxref("Boolean")}}对象或{{jsxref("Boolean")}}字面量的原始值作为布尔数据类型。</p>
+
+<p>该方法通常在 JavaScript 内部调用,而不是在代码中显式调用。</p>
+
+<h2 id="Examples" name="Examples">示例</h2>
+
+<h3 id="Example:_Using_valueOf" name="Example:_Using_valueOf">使用 <code>valueOf</code></h3>
+
+<pre class="brush: js">x = new Boolean();
+myVar = x.valueOf() // assigns false to myVar
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.1.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.6.4.3', 'Boolean.prototype.valueOf')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-boolean.prototype.valueof', 'Boolean.prototype.valueOf')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-boolean.prototype.valueof', 'Boolean.prototype.valueOf')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<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.Boolean.valueOf")}}</p>
+
+<h2 id="See_Also" name="See_Also">相关链接</h2>
+
+<ul>
+ <li>{{jsxref("Object.prototype.valueOf()")}}</li>
+</ul>