Get the description of a ES6 Symbol

后端 未结 4 517
渐次进展
渐次进展 2020-11-29 10:11

I wonder if there is a nice way to get the descriptions of a Symbol.

For example,

var s = Symbol(5);

The default implementation of

4条回答
  •  离开以前
    2020-11-29 10:49

    There is no neat way to do this. However, if you have registered a symbol in the global registry, you can use Symbol.keyFor():

    var s = Symbol.for(5);
    console.log(Symbol.keyFor(s));
    

提交回复
热议问题