4 ms·
Actually that only works with Map. For plain objects the key is always the stringified cast of the key. > o = { [{}]: 1 } { '[object Object]': 1 }
by mediumdeviation 3y ago
Actually that only works with Map. For plain objects the key is always the stringified cast of the key.
> o = { [{}]: 1 }
{ '[object Object]': 1 }
> k = { toString() { return 'a' } }
{ toString: [Function: toString] }
> o = { [k]: 1 }
{ a: 1 }
- aragonite 3y agoRight ... and it seems it's not even possible to simulate object keys using Proxy traps: new Proxy( {}, { get(target, property) { return typeof property }, }, )[{}] === 'string'