For example, if I use toString():
let s = Symbol('abc')
console.log(s.toString())
I get:
'Symbol(abc)'
How to get just the:
'abc'
part instead?
I know how to do this with string manipulation, but I would hope for a potentially more efficient solution that directly obtains the value.
I am using Symbol to implement an Enum: What is the preferred syntax for defining enums in JavaScript? and want to serialize it with a toJSON() on the containing class.
Tested in Node.js v10.15.1.