If sym is a passable symbol, return a string that uniquely identifies this
symbol. If sym is a non-passable symbol, return undefined.
The passable symbols are the well known symbols (the symbol values
of static properties of the Symbol constructor) and the registered
symbols. Since the registration string of a registered symbol can be any
string, if we simply used that to identify those symbols, there would not
be any remaining strings left over to identify the well-known symbols.
Instead, we reserve strings beginning with "@@" for purposes of this
encoding. We identify a well known symbol such as Symbol.iterator
by prefixing the property name with "@@", such as "@@iterator".
For registered symbols whose name happens to begin with "@@", such
as Symbol.for('@@iterator') or Symbol.for('@@foo'), we identify
them by prefixing them with an extra "@@", such as
"@@@@iterator" or "@@@@foo". (This is the Hilbert Hotel encoding
technique.)
If
sym
is a passable symbol, return a string that uniquely identifies this symbol. Ifsym
is a non-passable symbol, returnundefined
.The passable symbols are the well known symbols (the symbol values of static properties of the
Symbol
constructor) and the registered symbols. Since the registration string of a registered symbol can be any string, if we simply used that to identify those symbols, there would not be any remaining strings left over to identify the well-known symbols. Instead, we reserve strings beginning with"@@"
for purposes of this encoding. We identify a well known symbol such asSymbol.iterator
by prefixing the property name with"@@"
, such as"@@iterator"
. For registered symbols whose name happens to begin with"@@"
, such asSymbol.for('@@iterator')
orSymbol.for('@@foo')
, we identify them by prefixing them with an extra"@@"
, such as"@@@@iterator"
or"@@@@foo"
. (This is the Hilbert Hotel encoding technique.)