过时
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.
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.
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toSource
非标
|
Chrome No | Edge No |
Firefox
36 — 74
|
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 |
完整支持
不支持
非标。预期跨浏览器支持较差。
见实现注意事项。
Symbol
Symbol.for()
Symbol.keyFor()
Symbol.prototype.toSource()
Symbol.prototype.toString()
Symbol.prototype.valueOf()
Symbol.prototype[@@toPrimitive]
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()