# 符号
¥Symbol
表示唯一全局符号的原始数据类型。
¥A primitive data type representing a unique global symbol.
符号类型与 JavaScript 的 (MDN (opens new window)) 非常相似,但尚未与编译器深度集成。
¥The symbol type is very similar to JavaScript's (MDN (opens new window)), but is not deeply integrated with the compiler yet.
# 构建
¥Construction
- function Symbol(description?: string): symbol- 创建一个新的独特符号。请注意,这不是构造函数(符号是原始数据类型),因此不能使用 - new调用。- ¥Creates a new unique symbol. Note that this is not a constructor (symbols are primitive data types) so cannot be invoked with - new.
# 静态成员
¥Static members
- function for(key: string): symbol- 获取指定全局键的现有唯一符号,如果该键不存在,则创建新的唯一符号。 - ¥Obtains the existing unique symbol for the specified global key or creates a new unique symbol if the key does not exist. 
- function keyFor(sym: symbol): string | null- 获取指定唯一符号的全局密钥(如果有)。 - ¥Obtains the global key of the specified unique symbol, if any. 
# 实例成员
¥Instance members
- function toString(): string- 返回 - "Symbol(key?)"形式的符号的字符串表示形式。- ¥Returns a string representation of the symbol of the form - "Symbol(key?)".
← 字符串 TypedArray →