过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

toSource() method returns a string representing the source code of the object.

This method is usually called internally by JavaScript.

句法

Symbol.toSource()
var sym = Symbol()
sym.toSource()
					

返回值

A string representing the source code of the object.

范例

Native function

For the built-in Symbol 对象, toSource returns the following string indicating that the source code is not available:

"function Symbol() {
   [native code]
}"
					

For instances of Symbol , toSource returns a string representing the source code.

"Symbol()"
					

规范

Not part of any standard.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
toSource 非标 Chrome No Edge No Firefox 36 — 74
不支持 36 — 74
Starting in Firefox 74, toSource() is no longer available for use by web content. It is still allowed for internal and privileged code.
IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 36 Opera Android No Safari iOS No Samsung Internet Android No nodejs No

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

另请参阅

元数据

  • 最后修改: