Symbol.for() 和 Symbol.keyFor()
Symbol.for()
Symbol.for()let a = Symbol.for('test')
let b = Symbol.for('test')
console.log(a === b) // trueSymbol.forKey()
Symbol.forKey() const a = Symbol('test')
const b = Symbol.for('test_2')
console.log(Symbol.keyFor(a)) // undefined
console.log(Symbol.keyFor(b)) // test_2
Last updated