symbol.@@toPrimitive
[@@toPrimitive]() 方法可将 Symbol 对象转换为原始值。
语法
Symbol()[Symbol.toPrimitive](hint);返回值
该原始值为指定的Symbol对象
描述
Symbol的 [@@toPrimitive]() 方法返回该 Symbol 对象原始值作为 Symbol 数据形式。 hint参数未被使用。
JavaScript 调用[@@toPrimitive]() 方法将一个对象转换为原始值表示。你不需要自己调用 [@@toPrimitive]()方法;当对象需要被转换为原始值时,JavaScript 会自动地调用该方法。
规范
Specification | Status | Comment |
|---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Symbol.prototype.@@toPrimitive' in that specification. | Standard | Initial definition. |
ECMAScript 2017 Draft (ECMA-262)The definition of 'Symbol.prototype.@@toPrimitive' in that specification. | Draft | |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
Basic support | ? | 44.0 (44.0) | ? | ? | ? |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
Basic support | ? | ? | 44.0 (44.0) | ? | ? | ? |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

