Symbol.keyFor

# Axel Rauschmayer (12 years ago)

One problem with that method name: it overloads the term “key”. At the moment, property keys are either strings or symbols. If a symbol can also have a key, I’d find that confusing.

# Mark S. Miller (12 years ago)

Suggestions?

# Axel Rauschmayer (12 years ago)

Offhand, ID instead of key, but that is awfully generic. It may make sense to invent a new term.

# Bill Frantz (12 years ago)

In KeyKOS we used the word "name". We had another meaning for the word "key" and wanted to avoid confusion.

# Kevin Smith (12 years ago)

"Name" is good.

Symbol.name(Symbol.for("foo")) === "foo";

Or some variant thereof.

# Rick Waldron (12 years ago)

I like this, but it interferes with the name property that all function objects have—the Symbol.name property would no longer have the expected value "Symbol".

# Kevin Smith (12 years ago)

Oh yes - doh! : )