diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html new file mode 100644 index 0000000000..3a4624f560 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/@@toprimitive/index.html @@ -0,0 +1,55 @@ +--- +title: 'Symbol.prototype[@@toPrimitive]' +slug: Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive +translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive +--- +<div>{{JSRef}}</div> + +<p><code><strong>[@@toPrimitive]()</strong></code> 方法可将 Symbol 对象转换为原始值。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>Symbol()[Symbol.toPrimitive](hint); +</var></pre> + +<h3 id="返回值">返回值</h3> + +<p>该原始值为指定的 {{jsxref("Symbol")}} 对象</p> + +<h2 id="描述">描述</h2> + +<p> {{jsxref("Symbol")}} 的 <code>[@@toPrimitive]()</code> 方法返回该 Symbol 对象原始值作为 Symbol 数据形式。 <code>hint</code> 参数未被使用。</p> + +<p>JavaScript 调用 <code>[@@toPrimitive]() </code>方法将一个对象转换为原始值表示。你不需要自己调用 <code>[@@toPrimitive]()</code> 方法;当对象需要被转换为原始值时,JavaScript 会自动地调用该方法。</p> + +<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('ES6', '#sec-symbol.prototype-@@toprimitive', 'Symbol.prototype.@@toPrimitive')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-symbol.prototype-@@toprimitive', 'Symbol.prototype.@@toPrimitive')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{Compat("javascript.builtins.Symbol.@@toPrimitive")}}</p> + +<h2 id="参考资料">参考资料</h2> + +<ul> + <li>{{jsxref("Symbol.toPrimitive")}}</li> +</ul> |