首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

symbol.@@toPrimitive

[@@toPrimitive]() 方法可将 Symbol 对象转换为原始值。

语法

代码语言:javascript
复制
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)

?

?

?

扫码关注腾讯云开发者

领取腾讯云代金券