跳至主要內容

Symbol 断言

小于 1 分钟featurees-proposal

Symbol 断言open in new window

模块

类型

interface SymbolConstructor {
  isRegisteredSymbol(value: symbol): boolean;
  isWellKnownSymbol(value: symbol): boolean;
}

入口点

core-js/proposals/symbol-predicates-v2
core-js(-pure)/full/symbol/is-registered-symbol
core-js(-pure)/full/symbol/is-well-known-symbol

示例

示例open in new window

Symbol.isRegisteredSymbol(Symbol.for("key")); // => true
Symbol.isRegisteredSymbol(Symbol("key")); // => false
Symbol.isWellKnownSymbol(Symbol.iterator); // => true
Symbol.isWellKnownSymbol(Symbol("key")); // => false