I have an object fetched from 3rd party API as shown below:
{
name:\"Luke Skywalker\",
__typename:\"People\",
Symbol(id):\"ROOT_QUERY.people.\"
}
You can use Object.getOwnPropertySymbols() to retrieve it, but this would retrieve all symbols tied to an object. If you want to get that particular symbol on the object directly, you need to store that Symbol object else to be re-used.
const sym = Symbol(id);
const example = {
name:"Luke Skywalker",
__typename:"People",
[sym]:"ROOT_QUERY.people."
}
console.log(example[sym]) //Equals "ROOT_QUERY.people."