I have a code but it doesn't work. Why doesn't it work although new Set is an object. Or does Symbol.toPrimitive() work only with objects created with {}, Object.create() etc?
const obj = new Set(['a', 'b', 'c'])
obj[Symbol.toPrimitive] = function(hint) {
if (hint == 'string') return 'string'
}
console.log('String:', obj)